]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
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)
committerKarolin Seeger <kseeger@samba.org>
Fri, 21 Apr 2017 07:11:16 +0000 (09:11 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 16c89835cf07caa2082b586666095deba38ef962)

source3/modules/vfs_shadow_copy2.c

index 93ddb1cb28f76ea32e3478f75721707f704bdacf..08ca42b0c266b811762946a701eb171a2be1782e 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] == '/') {