last_gid = file->gid;
last_time = file->modtime;
- strncpy(lastname,fname,MAXPATHLEN-1);
+ strlcpy(lastname,fname,MAXPATHLEN-1);
lastname[MAXPATHLEN-1] = 0;
}
if (l2 >= MAXPATHLEN-l1) overflow("receive_file_entry");
- strncpy(thisname,lastname,l1);
+ strlcpy(thisname,lastname,l1);
read_sbuf(f,&thisname[l1],l2);
thisname[l1+l2] = 0;
- strncpy(lastname,thisname,MAXPATHLEN-1);
+ strlcpy(lastname,thisname,MAXPATHLEN-1);
lastname[MAXPATHLEN-1] = 0;
clean_fname(thisname);
+ if (relative_paths && thisname[0] == '/') {
+ /* strip / off absolute paths in destination */
+ memmove(thisname, thisname+1, strlen(thisname));
+ if (!thisname[0]) strcpy(thisname,".");
+ }
+
if ((p = strrchr(thisname,'/'))) {
static char *lastdir;
*p = 0;
char *p;
char cleaned_name[MAXPATHLEN];
- strncpy(cleaned_name, fname, MAXPATHLEN-1);
+ strlcpy(cleaned_name, fname, MAXPATHLEN-1);
cleaned_name[MAXPATHLEN-1] = 0;
clean_fname(cleaned_name);
fname = cleaned_name;
d = opendir(dir);
if (!d) {
io_error = 1;
- rprintf(FERROR,"%s: %s\n",
+ rprintf(FERROR,"opendir(%s): %s\n",
dir,strerror(errno));
return;
}
- strncpy(fname,dir,MAXPATHLEN-1);
- fname[MAXPATHLEN-1]=0;
+ strlcpy(fname,dir,MAXPATHLEN-1);
l = strlen(fname);
if (fname[l-1] != '/') {
if (l == MAXPATHLEN-1) {
closedir(d);
return;
}
- strcat(fname,"/");
+ strlcat(fname,"/", MAXPATHLEN-1);
l++;
}
p = fname + strlen(fname);
if (strcmp(dname,".")==0 ||
strcmp(dname,"..")==0)
continue;
- strncpy(p,dname,MAXPATHLEN-(l+1));
+ strlcpy(p,dname,MAXPATHLEN-(l+1));
send_file_name(f,flist,fname,recurse,FLAG_DELETE);
}
flist->malloced);
if (!flist->files) out_of_memory("send_file_list");
+ if (f != -1) {
+ io_start_buffering(f);
+ }
+
for (i=0;i<argc;i++) {
char fname2[MAXPATHLEN];
char *fname = fname2;
- strncpy(fname,argv[i],MAXPATHLEN-1);
- fname[MAXPATHLEN-1] = 0;
+ strlcpy(fname,argv[i],MAXPATHLEN-1);
l = strlen(fname);
if (l != 1 && fname[l-1] == '/') {
- strcat(fname,".");
+ strlcat(fname,".",MAXPATHLEN-1);
}
if (link_stat(fname,&st) != 0) {
thus getting their permissions right */
*p = 0;
if (strcmp(lastpath,fname)) {
- strcpy(lastpath, fname);
+ strlcpy(lastpath, fname, sizeof(lastpath)-1);
*p = '/';
for (p=fname+1; (p=strchr(p,'/')); p++) {
+ int copy_links_saved = copy_links;
*p = 0;
+ copy_links = 0;
send_file_name(f, flist, fname, 0, 0);
+ copy_links = copy_links_saved;
*p = '/';
}
} else {
if (f != -1) {
send_file_entry(NULL,f,0);
- write_flush(f);
}
if (verbose && recurse && !am_server && f != -1)
write_int(f, io_error);
}
+ if (f != -1) {
+ io_end_buffering(f);
+ write_flush(f);
+ }
+
if (verbose > 2)
rprintf(FINFO,"send_file_list done\n");
n = (n+1)%10;
if (f->dirname) {
- sprintf(p, "%s/%s", f->dirname, f->basename);
+ slprintf(p, MAXPATHLEN-1, "%s/%s", f->dirname, f->basename);
} else {
- strcpy(p, f->basename);
+ strlcpy(p, f->basename, MAXPATHLEN-1);
}
return p;