X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/65b4e4b2a93de8e5bff93b5c7a2a529613cbc5e8..62a6b8df72d18f0b13462ee7ac33f9a8a46ef0b5:/flist.c diff --git a/flist.c b/flist.c index 0893b4a0..960e6a11 100644 --- a/flist.c +++ b/flist.c @@ -351,7 +351,7 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_ static uint32 rdev_major; static uid_t uid; static gid_t gid; - static char *user_name, *group_name; + static const char *user_name, *group_name; static char lastname[MAXPATHLEN]; char fname[MAXPATHLEN]; int first_hlink_ndx = -1; @@ -389,6 +389,7 @@ static void send_file_entry(int f, struct file_struct *file, int ndx, int first_ /* Initialize starting value of xflags. */ if (protocol_version >= 30 && S_ISDIR(file->mode)) { + dir_count++; if (file->flags & FLAG_CONTENT_DIR) xflags = file->flags & FLAG_TOP_DIR; else if (file->flags & FLAG_IMPLIED_DIR) @@ -1111,7 +1112,6 @@ struct file_struct *make_file(const char *fname, struct file_list *flist, extra_len += DIRNODE_EXTRA_CNT * EXTRA_LEN; if (relative_paths) extra_len += PTR_EXTRA_CNT * EXTRA_LEN; - dir_count++; pool = dir_flist->file_pool; } else pool = flist->file_pool; @@ -1232,11 +1232,14 @@ struct file_struct *make_file(const char *fname, struct file_list *flist, file->mode = save_mode; } - if (basename_len == 0+1) + if (basename_len == 0+1) { + if (!pool) + unmake_file(file); return NULL; + } if (unsort_ndx) - F_NDX(file) = dir_count - 1; + F_NDX(file) = dir_count; return file; } @@ -1971,7 +1974,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) file = send_file_name(f, flist, fbuf, &st, top_flags, ALL_FILTERS); if (inc_recurse) { - if (name_type == DOT_NAME) { + if (name_type == DOT_NAME && file) { if (send_dir_depth < 0) { send_dir_depth = 0; change_local_filter_dir(fbuf, len, send_dir_depth);