aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2015-12-05 11:10:24 -0800
committerWayne Davison <wayned@samba.org>2015-12-05 11:10:24 -0800
commit32de6b7cb47630c5d5ba3afe631faa42966d8490 (patch)
tree2de5fba870801dd1c5bfda83a8656345b8df16af
parentbb853b32055a16e983267c6f5b8244aac311fdf9 (diff)
downloadandroid_external_rsync-32de6b7cb47630c5d5ba3afe631faa42966d8490.tar.gz
android_external_rsync-32de6b7cb47630c5d5ba3afe631faa42966d8490.tar.bz2
android_external_rsync-32de6b7cb47630c5d5ba3afe631faa42966d8490.zip
Fix return of stat info from try_dests_reg().
The try_dests_reg() function could sometimes tweak the stat struct's info when it should have been left unchanged. This fixes bug 11545 (where an ACL check of a file that was mistakenly thought to be a directory failed).
-rw-r--r--generator.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/generator.c b/generator.c
index 3a4504f4..ddf44a02 100644
--- a/generator.c
+++ b/generator.c
@@ -895,23 +895,21 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
} while (basis_dir[++j] != NULL);
if (!match_level)
- return -1;
+ goto got_nothing_for_ya;
if (j != best_match) {
j = best_match;
pathjoin(cmpbuf, MAXPATHLEN, basis_dir[j], fname);
if (link_stat(cmpbuf, &sxp->st, 0) < 0)
- return -1;
+ goto got_nothing_for_ya;
}
if (match_level == 3 && !copy_dest) {
if (find_exact_for_existing) {
if (link_dest && real_st.st_dev == sxp->st.st_dev && real_st.st_ino == sxp->st.st_ino)
return -1;
- if (do_unlink(fname) < 0 && errno != ENOENT) {
- sxp->st = real_st;
- return -1;
- }
+ if (do_unlink(fname) < 0 && errno != ENOENT)
+ goto got_nothing_for_ya;
}
#ifdef SUPPORT_HARD_LINKS
if (link_dest) {
@@ -935,10 +933,8 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
return -2;
}
- if (find_exact_for_existing) {
- sxp->st = real_st;
- return -1;
- }
+ if (find_exact_for_existing)
+ goto got_nothing_for_ya;
if (match_level >= 2) {
#ifdef SUPPORT_HARD_LINKS
@@ -946,7 +942,7 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
#endif
if (!dry_run && copy_altdest_file(cmpbuf, fname, file) < 0) {
if (find_exact_for_existing) /* Can get here via hard-link failure */
- sxp->st = real_st;
+ goto got_nothing_for_ya;
return -1;
}
if (itemizing)
@@ -966,6 +962,10 @@ static int try_dests_reg(struct file_struct *file, char *fname, int ndx,
}
return FNAMECMP_BASIS_DIR_LOW + j;
+
+got_nothing_for_ya:
+ sxp->st = real_st;
+ return -1;
}
/* This is only called for non-regular files. We return -2 if we've finished