X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/deee574b1198a2886369f4ecbfbeaa6f851bb41d..4a19c3b254b01c298fe25d72f450a760278e9386:/flist.c diff --git a/flist.c b/flist.c index e8043c57..8b24b0a1 100644 --- a/flist.c +++ b/flist.c @@ -48,6 +48,8 @@ extern int preserve_uid; extern int preserve_gid; extern int relative_paths; extern int implied_dirs; +extern int ignore_perishable; +extern int non_perishable_cnt; extern int prune_empty_dirs; extern int copy_links; extern int copy_unsafe_links; @@ -253,7 +255,7 @@ static mode_t from_wire_mode(int mode) static void send_directory(int f, struct file_list *flist, char *fbuf, int len); -static char *flist_dir; +static const char *flist_dir; static int flist_dir_len; @@ -465,7 +467,7 @@ static void send_file_entry(struct file_struct *file, int f) #endif if (always_checksum && (S_ISREG(mode) || protocol_version < 28)) { - char *sum; + const char *sum; if (S_ISREG(mode)) sum = file->u.sum; else { @@ -752,8 +754,12 @@ struct file_struct *make_file(char *fname, struct file_list *flist, int save_errno = errno; /* See if file is excluded before reporting an error. */ if (filter_level != NO_FILTERS - && is_excluded(thisname, 0, filter_level)) + && (is_excluded(thisname, 0, filter_level) + || is_excluded(thisname, 1, filter_level))) { + if (ignore_perishable && save_errno != ENOENT) + non_perishable_cnt++; return NULL; + } if (save_errno == ENOENT) { #ifdef SUPPORT_LINKS /* Avoid "vanished" error if symlink points nowhere. */ @@ -803,8 +809,11 @@ struct file_struct *make_file(char *fname, struct file_list *flist, flags |= FLAG_MOUNT_POINT; } - if (is_excluded(thisname, S_ISDIR(st.st_mode) != 0, filter_level)) + if (is_excluded(thisname, S_ISDIR(st.st_mode) != 0, filter_level)) { + if (ignore_perishable) + non_perishable_cnt++; return NULL; + } if (lp_ignore_nonreadable(module_id)) { #ifdef SUPPORT_LINKS @@ -1207,7 +1216,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) } if (dir && *dir) { - static char *lastdir; + static const char *lastdir; static int lastdir_len; strlcpy(olddir, curr_dir, sizeof olddir); @@ -1228,11 +1237,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) } } - if (fn != fbuf) { - if (len >= MAXPATHLEN) - overflow_exit("send_file_list"); + if (fn != fbuf) memmove(fbuf, fn, len + 1); - } if (implied_dirs && (p=strrchr(fbuf,'/')) && p != fbuf) { /* Send the implied directories at the start of the @@ -1499,8 +1505,7 @@ struct file_list *flist_new(int with_hlink, char *msg) memset(flist, 0, sizeof (struct file_list)); - if (!(flist->file_pool = pool_create(FILE_EXTENT, 0, - out_of_memory, POOL_INTERN))) + if (!(flist->file_pool = pool_create(FILE_EXTENT, 0, out_of_memory, POOL_INTERN))) out_of_memory(msg); #ifdef SUPPORT_HARD_LINKS @@ -1700,15 +1705,15 @@ static void output_flist(struct file_list *flist) for (i = 0; i < flist->count; i++) { file = flist->files[i]; if ((am_root || am_sender) && preserve_uid) - sprintf(uidbuf, " uid=%ld", (long)file->uid); + snprintf(uidbuf, sizeof uidbuf, " uid=%ld", (long)file->uid); else *uidbuf = '\0'; if (preserve_gid && file->gid != GID_NONE) - sprintf(gidbuf, " gid=%ld", (long)file->gid); + snprintf(gidbuf, sizeof gidbuf, " gid=%ld", (long)file->gid); else *gidbuf = '\0'; if (!am_sender) - sprintf(depthbuf, "%d", file->dir.depth); + snprintf(depthbuf, sizeof depthbuf, "%d", file->dir.depth); rprintf(FINFO, "[%s] i=%d %s %s%s%s%s mode=0%o len=%.0f%s%s flags=%x\n", who, i, am_sender ? NS(file->dir.root) : depthbuf, file->dirname ? file->dirname : "", @@ -1876,9 +1881,9 @@ char *f_name(struct file_struct *f, char *fbuf) int len = strlen(f->dirname); memcpy(fbuf, f->dirname, len); fbuf[len] = '/'; - strcpy(fbuf + len + 1, f->basename); + strlcpy(fbuf + len + 1, f->basename, MAXPATHLEN - (len + 1)); } else - strcpy(fbuf, f->basename); + strlcpy(fbuf, f->basename, MAXPATHLEN); return fbuf; }