Skip to content

Commit

Permalink
Refuse a duplicate dirlist.
Browse files Browse the repository at this point in the history
  • Loading branch information
WayneD authored and tridge committed Jan 14, 2025
1 parent 9f86ddc commit 688f5c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions flist.c
Original file line number Diff line number Diff line change
Expand Up @@ -2584,6 +2584,15 @@ struct file_list *recv_file_list(int f, int dir_ndx)
init_hard_links();
#endif

if (inc_recurse && dir_ndx >= 0) {
struct file_struct *file = dir_flist->files[dir_ndx];
if (file->flags & FLAG_GOT_DIR_FLIST) {
rprintf(FERROR_XFER, "rsync: refusing malicious duplicate flist for dir %d\n", dir_ndx);
exit_cleanup(RERR_PROTOCOL);
}
file->flags |= FLAG_GOT_DIR_FLIST;
}

flist = flist_new(0, "recv_file_list");
flist_expand(flist, FLIST_START_LARGE);

Expand Down
1 change: 1 addition & 0 deletions rsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
#define FLAG_DUPLICATE (1<<4) /* sender */
#define FLAG_MISSING_DIR (1<<4) /* generator */
#define FLAG_HLINKED (1<<5) /* receiver/generator (checked on all types) */
#define FLAG_GOT_DIR_FLIST (1<<5)/* sender/receiver/generator - dir_flist only */
#define FLAG_HLINK_FIRST (1<<6) /* receiver/generator (w/FLAG_HLINKED) */
#define FLAG_IMPLIED_DIR (1<<6) /* sender/receiver/generator (dirs only) */
#define FLAG_HLINK_LAST (1<<7) /* receiver/generator */
Expand Down

0 comments on commit 688f5c3

Please sign in to comment.