From: Wayne Davison Date: Sat, 16 Mar 2019 18:12:53 +0000 (-0700) Subject: Fix bug in try_dests_reg that Florian Zumbiehl pointed out. X-Git-Tag: v3.2.0pre1~200 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d47d3792160210ce14700e38a223eaa0059f3551;p=thirdparty%2Frsync.git Fix bug in try_dests_reg that Florian Zumbiehl pointed out. If the alternate-destination code was scanning multiple alt dirs and it found the right size/mtime/checksum info but not the right xattrs, it would keep scanning the other dirs for a better xattr match, but it would omit the unchanged-file check that needs to happen first. --- diff --git a/generator.c b/generator.c index 6021a220..5538a92d 100644 --- a/generator.c +++ b/generator.c @@ -876,27 +876,22 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx, pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname); if (link_stat(cmpbuf, &sxp->st, 0) < 0 || !S_ISREG(sxp->st.st_mode)) continue; - switch (match_level) { - case 0: + if (match_level == 0) { best_match = j; match_level = 1; - /* FALL THROUGH */ - case 1: - if (!unchanged_file(cmpbuf, file, &sxp->st)) - continue; + } + if (!unchanged_file(cmpbuf, file, &sxp->st)) + continue; + if (match_level == 1) { best_match = j; match_level = 2; - /* FALL THROUGH */ - case 2: - if (!unchanged_attrs(cmpbuf, file, sxp)) { - free_stat_x(sxp); - continue; - } + } + if (unchanged_attrs(cmpbuf, file, sxp)) { best_match = j; match_level = 3; break; } - break; + free_stat_x(sxp); } while (basis_dir[++j] != NULL); if (!match_level)