summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2005-10-15 19:08:31 +0000
committerWayne Davison <wayned@samba.org>2005-10-15 19:08:31 +0000
commit7e43da819e205f936b56a1b7be306e4f8b113d60 (patch)
tree22121aca8f67915f481276a34754eb214d070afb /util.c
parent40aaa571b4b16f62438f5df05295f965fbea4dc8 (diff)
downloadrsync-7e43da819e205f936b56a1b7be306e4f8b113d60.tar.gz
rsync-7e43da819e205f936b56a1b7be306e4f8b113d60.tar.bz2
rsync-7e43da819e205f936b56a1b7be306e4f8b113d60.zip
If we're sanitizing paths with --relative enabled, we need to
preserve the first /./ dir so that we can use its position to trim the implied directories.
Diffstat (limited to 'util.c')
-rw-r--r--util.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/util.c b/util.c
index 9ebd6ba7..1297834a 100644
--- a/util.c
+++ b/util.c
@@ -31,6 +31,7 @@ extern int verbose;
extern int dry_run;
extern int module_id;
extern int modify_window;
+extern int relative_paths;
extern char *partial_dir;
extern struct filter_list_struct server_filter_list;
@@ -755,7 +756,7 @@ unsigned int clean_fname(char *name, BOOL collapse_dot_dot)
char *sanitize_path(char *dest, const char *p, const char *rootdir, int depth)
{
char *start, *sanp;
- int rlen = 0;
+ int rlen = 0, leave_one_dotdir = relative_paths;
if (dest != p) {
int plen = strlen(p);
@@ -790,9 +791,13 @@ char *sanitize_path(char *dest, const char *p, const char *rootdir, int depth)
* always be left pointing after a slash
*/
if (*p == '.' && (p[1] == '/' || p[1] == '\0')) {
- /* skip "." component */
- p++;
- continue;
+ if (leave_one_dotdir && p[1] && sanp != dest)
+ leave_one_dotdir = 0;
+ else {
+ /* skip "." component */
+ p++;
+ continue;
+ }
}
if (*p == '.' && p[1] == '.' && (p[2] == '/' || p[2] == '\0')) {
/* ".." component followed by slash or end */