From: Wayne Davison Date: Sun, 23 May 2004 23:46:56 +0000 (+0000) Subject: Improved the depth calculation in sanitize_path() so that it properly X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/commitdiff_plain/f9e5a0cde204b56a4dc77eae156c162a72f6d5a9 Improved the depth calculation in sanitize_path() so that it properly handles a trailing slash, a leading slash, and an empty string. --- diff --git a/util.c b/util.c index 22127231..4b46b35c 100644 --- a/util.c +++ b/util.c @@ -707,9 +707,12 @@ void sanitize_path(char *p, char *reldir) int allowdotdot = 0; if (reldir) { - depth++; + int new_component = 1; while (*reldir) { - if (*reldir++ == '/') { + if (*reldir++ == '/') + new_component = 1; + else if (new_component) { + new_component = 0; depth++; } }