From: Wayne Davison Date: Fri, 5 May 2006 15:54:20 +0000 (+0000) Subject: - Added a call to die_on_unsafe_path() to handle_partial_dir(). X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/89363676953c674450b68e9133193da83702e8a8 - Added a call to die_on_unsafe_path() to handle_partial_dir(). - Fixed some strange slash handling in partial_dir_fname(). --- diff --git a/util.c b/util.c index 337aa83f..12b88edd 100644 --- a/util.c +++ b/util.c @@ -1066,13 +1066,11 @@ char *partial_dir_fname(const char *fname) if ((int)pathjoin(t, sz, partial_dir, fn) >= sz) return NULL; if (server_filter_list.head) { - static int len; - if (!len) - len = strlen(partial_dir); - t[len] = '\0'; + t = strrchr(partial_fname, '/'); + *t = '\0'; if (check_filter(&server_filter_list, partial_fname, 1) < 0) return NULL; - t[len] = '/'; + *t = '/'; if (check_filter(&server_filter_list, partial_fname, 0) < 0) return NULL; } @@ -1098,6 +1096,8 @@ int handle_partial_dir(const char *fname, int create) if (create) { STRUCT_STAT st; int statret = do_lstat(dir, &st); + if (sanitize_paths && *partial_dir != '/') + die_on_unsafe_path(dir, 1); /* lstat handles last element */ if (statret == 0 && !S_ISDIR(st.st_mode)) { if (do_unlink(dir) < 0) return 0;