Commit b9232d45 authored by Wayne Davison's avatar Wayne Davison

- Fixed the reading of the fuzzy xname from the socket.

- Call read_item_attrs() with its new arg.
parent 6087ef2a
...@@ -303,25 +303,6 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r, ...@@ -303,25 +303,6 @@ static int receive_data(int f_in, char *fname_r, int fd_r, OFF_T size_r,
} }
static char *read_gen_name(int fd, char *dirname, char *buf)
{
int dlen;
if (dirname) {
dlen = strlcpy(buf, dirname, MAXPATHLEN);
if (dlen != 1 || *buf != '/')
buf[dlen++] = '/';
} else
dlen = 0;
if (read_vstring(fd, buf + dlen, MAXPATHLEN - dlen) < 0)
return NULL;
if (strchr(buf + dlen, '/') != NULL)
return NULL;
return buf;
}
static void discard_receive_data(int f_in, OFF_T length) static void discard_receive_data(int f_in, OFF_T length)
{ {
receive_data(f_in, NULL, -1, 0, NULL, -1, length); receive_data(f_in, NULL, -1, 0, NULL, -1, length);
...@@ -337,9 +318,9 @@ int recv_files(int f_in, struct file_list *flist, char *local_name) ...@@ -337,9 +318,9 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
int next_gen_i = -1; int next_gen_i = -1;
int fd1,fd2; int fd1,fd2;
STRUCT_STAT st; STRUCT_STAT st;
int iflags; int iflags, xlen;
char *fname, fbuf[MAXPATHLEN]; char *fname, fbuf[MAXPATHLEN];
char template[MAXPATHLEN]; char xname[MAXPATHLEN];
char fnametmp[MAXPATHLEN]; char fnametmp[MAXPATHLEN];
char *fnamecmp, *partialptr, numbuf[4]; char *fnamecmp, *partialptr, numbuf[4];
char fnamecmpbuf[MAXPATHLEN]; char fnamecmpbuf[MAXPATHLEN];
...@@ -386,7 +367,8 @@ int recv_files(int f_in, struct file_list *flist, char *local_name) ...@@ -386,7 +367,8 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
continue; continue;
} }
iflags = read_item_attrs(f_in, -1, i, fnametmp, &fnamecmp_type); iflags = read_item_attrs(f_in, -1, i, &fnamecmp_type,
xname, &xlen);
if (iflags == ITEM_IS_NEW) /* no-op packet */ if (iflags == ITEM_IS_NEW) /* no-op packet */
continue; continue;
...@@ -397,7 +379,7 @@ int recv_files(int f_in, struct file_list *flist, char *local_name) ...@@ -397,7 +379,7 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
rprintf(FINFO, "recv_files(%s)\n", safe_fname(fname)); rprintf(FINFO, "recv_files(%s)\n", safe_fname(fname));
if (!(iflags & ITEM_TRANSFER)) { if (!(iflags & ITEM_TRANSFER)) {
maybe_log_item(file, iflags, itemizing, fnametmp); maybe_log_item(file, iflags, itemizing, xname);
continue; continue;
} }
...@@ -447,8 +429,12 @@ int recv_files(int f_in, struct file_list *flist, char *local_name) ...@@ -447,8 +429,12 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
fnamecmp = get_backup_name(fname); fnamecmp = get_backup_name(fname);
break; break;
case FNAMECMP_FUZZY: case FNAMECMP_FUZZY:
fnamecmp = read_gen_name(f_in, file->dirname, if (file->dirname) {
fnamecmpbuf); pathjoin(fnamecmpbuf, MAXPATHLEN,
file->dirname, xname);
fnamecmp = fnamecmpbuf;
} else
fnamecmp = xname;
break; break;
default: default:
if (fnamecmp_type >= basis_dir_cnt) { if (fnamecmp_type >= basis_dir_cnt) {
...@@ -549,8 +535,6 @@ int recv_files(int f_in, struct file_list *flist, char *local_name) ...@@ -549,8 +535,6 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
continue; continue;
} }
strlcpy(template, fnametmp, sizeof template);
/* we initially set the perms without the /* we initially set the perms without the
* setuid/setgid bits to ensure that there is no race * setuid/setgid bits to ensure that there is no race
* condition. They are then correctly updated after * condition. They are then correctly updated after
...@@ -564,7 +548,8 @@ int recv_files(int f_in, struct file_list *flist, char *local_name) ...@@ -564,7 +548,8 @@ int recv_files(int f_in, struct file_list *flist, char *local_name)
* transferred, but that may not be the case with -R */ * transferred, but that may not be the case with -R */
if (fd2 == -1 && relative_paths && errno == ENOENT if (fd2 == -1 && relative_paths && errno == ENOENT
&& create_directory_path(fnametmp, orig_umask) == 0) { && create_directory_path(fnametmp, orig_umask) == 0) {
strlcpy(fnametmp, template, sizeof fnametmp); /* Get back to name with XXXXXX in it. */
get_tmpname(fnametmp, fname);
fd2 = do_mkstemp(fnametmp, file->mode & INITACCESSPERMS); fd2 = do_mkstemp(fnametmp, file->mode & INITACCESSPERMS);
} }
if (fd2 == -1) { if (fd2 == -1) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment