From: Jeremy Allison Date: Fri, 27 Jan 2017 00:08:42 +0000 (-0800) Subject: s3: smbtorture: Add new local test LOCAL-CANONICALIZE-PATH X-Git-Tag: talloc-2.1.9~307 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a51363309a4330b65e34ae941ec99d180bdbab56;p=thirdparty%2Fsamba.git s3: smbtorture: Add new local test LOCAL-CANONICALIZE-PATH Tests new canonicalize_absolute_path() function. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12531 Signed-off-by: Jeremy Allison Reviewed-by: Uri Simchoni --- diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index 3a6186c7db1..8e1c33d66f0 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -125,6 +125,7 @@ local_tests = [ "LOCAL-MESSAGING-FDPASS2a", "LOCAL-MESSAGING-FDPASS2b", "LOCAL-PTHREADPOOL-TEVENT", + "LOCAL-CANONICALIZE-PATH", "LOCAL-hex_encode_buf", "LOCAL-remove_duplicate_addrs2"] diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 073931e097e..1bd7d6e1393 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -11020,6 +11020,49 @@ static bool run_local_tdb_writer(int dummy) return true; } +static bool run_local_canonicalize_path(int dummy) +{ + const char *src[] = { + "/foo/..", + "/..", + "/foo/bar/../baz", + "/foo/././", + "/../foo", + ".././././", + ".././././../../../boo", + "./..", + NULL + }; + const char *dst[] = { + "/", + "/", + "/foo/baz", + "/foo", + "/foo", + "/", + "/boo", + "/", + NULL + }; + unsigned int i; + + for (i = 0; src[i] != NULL; i++) { + char *d = canonicalize_absolute_path(talloc_tos(), src[i]); + if (d == NULL) { + perror("talloc fail\n"); + return false; + } + if (strcmp(d, dst[i]) != 0) { + d_fprintf(stderr, + "canonicalize missmatch %s -> %s != %s", + src[i], d, dst[i]); + return false; + } + talloc_free(d); + } + return true; +} + static double create_procs(bool (*fn)(int), bool *result) { int i, status; @@ -11256,6 +11299,7 @@ static struct { { "LOCAL-DBWRAP-CTDB", run_local_dbwrap_ctdb, 0 }, { "LOCAL-BENCH-PTHREADPOOL", run_bench_pthreadpool, 0 }, { "LOCAL-PTHREADPOOL-TEVENT", run_pthreadpool_tevent, 0 }, + { "LOCAL-CANONICALIZE-PATH", run_local_canonicalize_path, 0 }, { "qpathinfo-bufsize", run_qpathinfo_bufsize, 0 }, {NULL, NULL, 0}};