From 35d49586ecb34e2ef01e2b94c7df236a223d1576 Mon Sep 17 00:00:00 2001 From: Denis Silakov Date: Fri, 11 Feb 2022 12:06:00 +0300 Subject: [PATCH] Do not try to access cur_flist->files at negative index when checking for non-regular file --- rsync.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rsync.c b/rsync.c index 102e72ed6..a93de4040 100644 --- a/rsync.c +++ b/rsync.c @@ -420,7 +420,13 @@ int read_ndx_and_attrs(int f_in, int f_out, int *iflag_ptr, uchar *type_ptr, cha if (iflags & ITEM_TRANSFER) { int i = ndx - cur_flist->ndx_start; - if (i < 0 || !S_ISREG(cur_flist->files[i]->mode)) { + if (i < 0) { + rprintf(FERROR, + "received request to transfer non-regular file: %d [%s]\n", + ndx, who_am_i()); + exit_cleanup(RERR_PROTOCOL); + } + if (!S_ISREG(cur_flist->files[i]->mode)) { rprintf(FERROR, "received request to transfer non-regular file: %d [%s]\n", ndx, who_am_i());