s3:vfs:shadow_copy2: fix the corner case if cwd=/ in make_relative_path
authorMichael Adam <obnox@samba.org>
Tue, 11 Apr 2017 10:03:20 +0000 (12:03 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 11 Apr 2017 23:41:13 +0000 (01:41 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_shadow_copy2.c

index f3ec8b61ab5e87f77e0d320ff767eb17029e8f77..83be84e50a82976316d33b6ac8344daf7bd099ae 100644 (file)
@@ -444,7 +444,11 @@ static bool make_relative_path(const char *cwd, char *abs_path)
        if (memcmp(abs_path, cwd, cwd_len) != 0) {
                return false;
        }
-       if (abs_path[cwd_len] != '/' && abs_path[cwd_len] != '\0') {
+       /* The cwd_len != 1 case is for $cwd == '/' */
+       if (cwd_len != 1 &&
+           abs_path[cwd_len] != '/' &&
+           abs_path[cwd_len] != '\0')
+       {
                return false;
        }
        if (abs_path[cwd_len] == '/') {