From: Michael Adam Date: Tue, 11 Apr 2017 10:03:20 +0000 (+0200) Subject: s3:vfs:shadow_copy2: fix the corner case if cwd=/ in make_relative_path X-Git-Tag: samba-4.5.9~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b0b84eda36483a2a6f17d0f9eb6c6e734e6ac71;p=thirdparty%2Fsamba.git s3:vfs:shadow_copy2: fix the corner case if cwd=/ in make_relative_path Signed-off-by: Michael Adam Reviewed-by: Jeremy Allison (cherry picked from commit 16c89835cf07caa2082b586666095deba38ef962) --- diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 93ddb1cb28f..08ca42b0c26 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -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] == '/') {