mirror of
https://github.com/transmission/transmission
synced 2025-02-22 14:10:34 +00:00
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:
parent
99c9b90965
commit
6da6629887
1 changed files with 23 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue