mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-03-10 10:27:13 -04:00
Fixed a couple minor problems in util.c:
- Make sure that handle_partial_dir() never returns a truncated fname. - Make robust_rename() return that it failed to do a cross-device copy if the partial-dir could not be created.
This commit is contained in:
10
util.c
10
util.c
@@ -437,7 +437,7 @@ int robust_rename(const char *from, const char *to, const char *partialptr,
|
||||
case EXDEV:
|
||||
if (partialptr) {
|
||||
if (!handle_partial_dir(partialptr,PDIR_CREATE))
|
||||
return -1;
|
||||
return -2;
|
||||
to = partialptr;
|
||||
}
|
||||
if (copy_file(from, to, -1, mode, 0) != 0)
|
||||
@@ -1112,12 +1112,16 @@ int handle_partial_dir(const char *fname, int create)
|
||||
STRUCT_STAT st;
|
||||
int statret = do_lstat(dir, &st);
|
||||
if (statret == 0 && !S_ISDIR(st.st_mode)) {
|
||||
if (do_unlink(dir) < 0)
|
||||
if (do_unlink(dir) < 0) {
|
||||
*fn = '/';
|
||||
return 0;
|
||||
}
|
||||
statret = -1;
|
||||
}
|
||||
if (statret < 0 && do_mkdir(dir, 0700) < 0)
|
||||
if (statret < 0 && do_mkdir(dir, 0700) < 0) {
|
||||
*fn = '/';
|
||||
return 0;
|
||||
}
|
||||
} else
|
||||
do_rmdir(dir);
|
||||
*fn = '/';
|
||||
|
||||
Reference in New Issue
Block a user