X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/2cd421d80978b9a1ab7ec0bd0eca50c03ef38a33..b6008dc6452b8173fde6e04ab327e34f74097026:/util.c diff --git a/util.c b/util.c index d8d396cf..72e08597 100644 --- a/util.c +++ b/util.c @@ -922,7 +922,8 @@ void die_on_unsafe_path(char *path, int strip_filename) if ((p = strchr(p, '/')) != NULL) *p = '\0'; if (safe_stat(path, &st) < 0) { - *p++ = '/'; + if (p) + *p = '/'; goto done; } if (S_ISLNK(st.st_mode)) { @@ -943,7 +944,7 @@ void die_on_unsafe_path(char *path, int strip_filename) /* Like chdir(), but it keeps track of the current directory (in the * global "curr_dir"), and ensures that the path size doesn't overflow. * Also cleans the path using the clean_fname() function. */ -int push_dir(char *dir) +int push_dir(char *dir, int set_path_only) { static int initialised; unsigned int len; @@ -964,7 +965,7 @@ int push_dir(char *dir) if ((*dir == '/' ? len : curr_dir_len + 1 + len) >= sizeof curr_dir) return 0; - if (chdir(dir)) + if (!set_path_only && chdir(dir)) return 0; if (*dir == '/') {