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.
This commit is contained in:
Mike Gelfand 2018-01-24 23:06:21 +03:00
parent 99c9b90965
commit 6da6629887
1 changed files with 23 additions and 0 deletions

View File

@ -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;
}