From: Mike Gelfand Date: Wed, 24 Jan 2018 20:06:21 +0000 (+0300) Subject: Add unit tests uncovering improper UNC paths resolution X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6da66298879ccb939cb0bbb32c1baf1ef062efed;p=transmission Add unit tests uncovering improper UNC paths resolution While resolved paths always contain the `\\?\` prefix, it's not always correct to strip only those 4 chars. In case of UNC paths, the prefix is actually a bit longer (`\\?\UNC\`) and needs to be replaced with `\\` instead. Failing to do so results in invalid paths, e.g. `\\Host\Share\File` becomes `UNC\Host\Share\File` which totally wrong. --- diff --git a/libtransmission/file-test.c b/libtransmission/file-test.c index 25aafed30..02dfd5ff4 100644 --- a/libtransmission/file-test.c +++ b/libtransmission/file-test.c @@ -635,6 +635,29 @@ static int test_path_resolve(void) tr_free(path2); tr_free(path1); +#ifdef _WIN32 + + { + char* tmp; + + tmp = tr_sys_path_resolve("\\\\127.0.0.1\\NonExistent", &err); + check_str(tmp, ==, NULL); + check_ptr(err, !=, NULL); + tr_error_clear(&err); + + tmp = tr_sys_path_resolve("\\\\127.0.0.1\\ADMIN$\\NonExistent", &err); + check_str(tmp, ==, NULL); + check_ptr(err, !=, NULL); + tr_error_clear(&err); + + tmp = tr_sys_path_resolve("\\\\127.0.0.1\\ADMIN$\\System32", &err); + check_str(tmp, ==, "\\\\127.0.0.1\\ADMIN$\\System32"); + check_ptr(err, ==, NULL); + tr_free(tmp); + } + +#endif + tr_free(test_dir); return 0; }