Fix possible array deref using invalid index.
authorWayne Davison <wayne@opencoder.net>
Mon, 21 Feb 2022 22:19:31 +0000 (14:19 -0800)
committerWayne Davison <wayne@opencoder.net>
Mon, 21 Feb 2022 22:19:31 +0000 (14:19 -0800)
copy-devices.diff

index 797d046017606106dc6ac08559565c660f82763e..413847480b15a0983fe8782e7dc0c4a835b4ae98 100644 (file)
@@ -8,7 +8,7 @@ To use this patch, run these commands for a successful build:
     ./configure                      (optional if already run)
     make
 
-based-on: cc832943160fb2cbaeaf45942b724828399edd37
+based-on: c51da9174f626f6da2b3bf46a045099aeef72175
 diff --git a/generator.c b/generator.c
 --- a/generator.c
 +++ b/generator.c
@@ -111,8 +111,8 @@ diff --git a/rsync.c b/rsync.c
        if (iflags & ITEM_TRANSFER) {
                int i = ndx - cur_flist->ndx_start;
 -              if (i < 0 || !S_ISREG(cur_flist->files[i]->mode)) {
-+              struct file_struct *file = cur_flist->files[i];
-+              if (i < 0 || !(S_ISREG(file->mode) || (copy_devices && IS_DEVICE(file->mode)))) {
++              if (i < 0
++               || !(S_ISREG(cur_flist->files[i]->mode) || (copy_devices && IS_DEVICE(cur_flist->files[i]->mode)))) {
                        rprintf(FERROR,
                                "received request to transfer non-regular file: %d [%s]\n",
                                ndx, who_am_i());