1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-08 11:56:11 +00:00

kernelbase: Don't strip leading dots in relative paths.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49315
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-05-24 08:20:25 +02:00 committed by Alexandre Julliard
parent 0da35c26a1
commit c27b2461a4
2 changed files with 26 additions and 1 deletions

View File

@ -1389,7 +1389,7 @@ BOOL WINAPI PathCanonicalizeW(WCHAR *buffer, const WCHAR *path)
{
src += 2; /* Skip .\ */
}
else if (src[1] == '.' && (dst == buffer || dst[-1] == '\\'))
else if (src[1] == '.' && dst != buffer && dst[-1] == '\\')
{
/* \.. backs up a directory, over the root if it has no \ following X:.
* .. is ignored if it would remove a UNC server name or initial \\

View File

@ -714,6 +714,15 @@ static void test_PathCombineA(void)
ok(!lstrcmpA(str, "C:\\"), "Expected C:\\, got %s\n", str);
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
/* try relative paths */
/* try forward slashes */
SetLastError(0xdeadbeef);
lstrcpyA(dest, "control");
str = PathCombineA(dest, "../../../one/two/", "*");
ok(str == dest, "Expected str == dest, got %p\n", str);
ok(!lstrcmpA(str, "../../../one/two/\\*"), "Expected ../../../one/two/\\*, got %s\n", str);
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
memset(too_long, 'a', LONG_LEN);
too_long[LONG_LEN - 1] = '\0';
@ -1039,6 +1048,22 @@ static void test_PathCanonicalizeA(void)
!lstrcmpA(dest, "C:\\one/"), /* Vista */
"Expected \"C:\\one/.\" or \"C:\\one/\", got \"%s\"\n", dest);
/* try relative forward slashes */
lstrcpyA(dest, "test");
SetLastError(0xdeadbeef);
res = PathCanonicalizeA(dest, "../../one/two/");
ok(res, "Expected success\n");
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
ok(!lstrcmpA(dest, "../../one/two/"), "Expected ../../one/two/, got %s\n", dest);
/* try relative forward slashes */
lstrcpyA(dest, "test");
SetLastError(0xdeadbeef);
res = PathCanonicalizeA(dest, "../../one/two/\\*");
ok(res, "Expected success\n");
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
ok(!lstrcmpA(dest, "../../one/two/\\*"), "Expected ../../one/two/\\*, got %s\n", dest);
/* try forward slashes with change dirs
* NOTE: if there is a forward slash in between two backslashes,
* everything in between the two backslashes is considered on dir