X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/3f0211b63a6cdc4a2cecfd2a0dffeba172c86a47..65b4e4b2a93de8e5bff93b5c7a2a529613cbc5e8:/rsync.c diff --git a/rsync.c b/rsync.c index c5bcbb5a..1654c30a 100644 --- a/rsync.c +++ b/rsync.c @@ -264,12 +264,13 @@ int read_ndx_and_attrs(int f_in, int *iflag_ptr, uchar *type_ptr, } if (!(flist = flist_for_ndx(ndx))) { + int start, used; invalid_ndx: + start = first_flist ? first_flist->ndx_start : 0; + used = first_flist ? first_flist->used : 0; rprintf(FERROR, "Invalid file index: %d (%d - %d) with iflags %x [%s]\n", - ndx, first_flist ? first_flist->ndx_start - 1 : -1, - first_flist ? first_flist->prev->ndx_end : -1, - iflags, who_am_i()); + ndx, start - 1, start + used -1, iflags, who_am_i()); exit_cleanup(RERR_PROTOCOL); } cur_flist = flist; @@ -371,16 +372,19 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp, new_mode |= S_ISGID; } + if (daemon_chmod_modes && !S_ISLNK(new_mode)) + new_mode = tweak_mode(new_mode, daemon_chmod_modes); + #ifdef SUPPORT_ACLS if (preserve_acls && !S_ISLNK(file->mode) && !ACL_READY(*sxp)) get_acl(fname, sxp); #endif #ifdef SUPPORT_XATTRS + if (am_root < 0) + set_stat_xattr(fname, file, new_mode); if (preserve_xattrs && fnamecmp) set_xattr(fname, file, fnamecmp, sxp); - if (am_root < 0) - set_stat_xattr(fname, file); #endif if (!preserve_times || (S_ISDIR(sxp->st.st_mode) && preserve_times == 1)) @@ -440,9 +444,6 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp, updated = 1; } - if (daemon_chmod_modes && !S_ISLNK(new_mode)) - new_mode = tweak_mode(new_mode, daemon_chmod_modes); - #ifdef SUPPORT_ACLS /* It's OK to call set_acl() now, even for a dir, as the generator * will enable owner-writability using chmod, if necessary. @@ -572,7 +573,7 @@ struct file_list *flist_for_ndx(int ndx) return NULL; flist = flist->prev; } - while (ndx > flist->ndx_end) { + while (ndx >= flist->ndx_start + flist->used) { if (!(flist = flist->next)) return NULL; }