Skip to content

Commit

Permalink
Avoid crash of transfer logging w/default log format.
Browse files Browse the repository at this point in the history
  • Loading branch information
WayneD committed Jun 30, 2020
1 parent 7a413c9 commit 317beeb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Protocol: 31 (unchanged)

### BUG FIXES:

- Avoid a crash when a daemon module enables `transfer logging` without
setting a `log format` value.

- Fixed installing rsync-ssl script from an alternate build dir.

- Fixed the updating of configure.sh from an alternate build dir.
Expand Down
19 changes: 9 additions & 10 deletions loadparm.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,25 +463,25 @@ void reset_daemon_vars(void)

/* Expand %VAR% references. Any unknown vars or unrecognized
* syntax leaves the raw chars unchanged. */
static char *expand_vars(char *str)
static char *expand_vars(const char *str)
{
char *buf, *t, *f;
char *buf, *t;
const char *f;
int bufsize;

if (!str || !strchr(str, '%'))
return str;
return (char *)str; /* TODO change return value to const char* at some point. */

bufsize = strlen(str) + 2048;
buf = new_array(char, bufsize+1); /* +1 for trailing '\0' */

for (t = buf, f = str; bufsize && *f; ) {
if (*f == '%' && *++f != '%') {
char *percent = strchr(f, '%');
if (percent) {
if (*f == '%' && isUpper(f+1)) {
char *percent = strchr(f+1, '%');
if (percent && percent - f < bufsize) {
char *val;
*percent = '\0';
val = getenv(f);
*percent = '%';
strlcpy(t, f+1, percent - f);
val = getenv(t);
if (val) {
int len = strlcpy(t, val, bufsize+1);
if (len > bufsize)
Expand All @@ -492,7 +492,6 @@ static char *expand_vars(char *str)
continue;
}
}
f--;
}
*t++ = *f++;
bufsize--;
Expand Down
6 changes: 5 additions & 1 deletion testsuite/rsync.fns
Original file line number Diff line number Diff line change
Expand Up @@ -297,25 +297,29 @@ use chroot = no
munge symlinks = no
hosts allow = localhost 127.0.0.0/24 192.168.0.0/16 10.0.0.0/8 $hostname
log file = $logfile
log format = %i %h [%a] %m (%u) %l %f%L
transfer logging = yes
# We don't define log format here so that the test-hidden module will default
# to the internal static string (since we had a crash trying to tweak it).
exclude = ? foobar.baz
max verbosity = 4
$uid_setting
$gid_setting
[test-from]
path = $fromdir
log format = %i %h [%a] %m (%u) %l %f%L
read only = yes
comment = r/o
[test-to]
path = $todir
log format = %i %h [%a] %m (%u) %l %f%L
read only = no
comment = r/w
[test-scratch]
path = $scratchdir
log format = %i %h [%a] %m (%u) %l %f%L
read only = no
[test-hidden]
Expand Down

0 comments on commit 317beeb

Please sign in to comment.