From: Jeremy Allison Date: Tue, 21 Apr 2020 19:58:02 +0000 (-0700) Subject: s3: lib: Fix canonicalize_absolute_path() to pass the tests from resolve_realpath_name() X-Git-Tag: ldb-2.2.0~895 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d01e11cf261003ecf332765538216cff7001163d;p=thirdparty%2Fsamba.git s3: lib: Fix canonicalize_absolute_path() to pass the tests from resolve_realpath_name() Remove the knownfail. Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/selftest/knownfail.d/local_canonicalize_path b/selftest/knownfail.d/local_canonicalize_path deleted file mode 100644 index 477c60a68eb..00000000000 --- a/selftest/knownfail.d/local_canonicalize_path +++ /dev/null @@ -1,2 +0,0 @@ -samba3.smbtorture_s3.LOCAL-CANONICALIZE-PATH - diff --git a/source3/lib/util_path.c b/source3/lib/util_path.c index 63d01b81000..fed0cc34d1c 100644 --- a/source3/lib/util_path.c +++ b/source3/lib/util_path.c @@ -130,7 +130,13 @@ char *canonicalize_absolute_path(TALLOC_CTX *ctx, const char *abs_path) s++; } if ((d > destname + 1) && (*s != '\0')) { - *d++ = '/'; + if (!start_of_name_component) { + /* + * Only write a / if we + * haven't just written one. + */ + *d++ = '/'; + } } start_of_name_component = true; continue; @@ -178,6 +184,12 @@ char *canonicalize_absolute_path(TALLOC_CTX *ctx, const char *abs_path) continue; } + /* + * Step forward one to leave the + * last written '/' alone. + */ + d++; + /* * We're still at the start of a name * component, just the previous one.