From 33c65845c7841e2766d25ec370d6723a6dc5c38b Mon Sep 17 00:00:00 2001 From: "Erich E. Hoover" Date: Mon, 15 Jun 2015 22:20:03 -0600 Subject: kernel32: Handle device paths in GetVolumePathName. --- dlls/kernel32/tests/volume.c | 8 ++++++++ dlls/kernel32/volume.c | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c index 7ed55d7..4349ec4 100644 --- a/dlls/kernel32/tests/volume.c +++ b/dlls/kernel32/tests/volume.c @@ -675,6 +675,14 @@ static void test_GetVolumePathNameA(void) "InvalidDrive:\\AnInvalidFolder", "%CurrentDrive%\\", sizeof(volume_path), NO_ERROR, NO_ERROR }, + { /* test 18: a reasonable device path */ + "\\??\\CdRom0", "%CurrentDrive%\\", sizeof(volume_path), + NO_ERROR, NO_ERROR + }, + { /* test 19: an unreasonable device path */ + "\\??\\ReallyBogus", "%CurrentDrive%\\", sizeof(volume_path), + NO_ERROR, NO_ERROR + }, }; BOOL ret, success; DWORD error; diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c index e135967..7c80cb1 100644 --- a/dlls/kernel32/volume.c +++ b/dlls/kernel32/volume.c @@ -1817,6 +1817,7 @@ BOOL WINAPI GetVolumePathNameA(LPCSTR filename, LPSTR volumepathname, DWORD bufl */ BOOL WINAPI GetVolumePathNameW(LPCWSTR filename, LPWSTR volumepathname, DWORD buflen) { + const WCHAR deviceprefixW[] = { '\\','?','?','\\',0 }; const WCHAR ntprefixW[] = { '\\','\\','?','\\',0 }; WCHAR fallbackpathW[] = { 'C',':','\\',0 }; NTSTATUS status = STATUS_SUCCESS; @@ -1892,9 +1893,9 @@ BOOL WINAPI GetVolumePathNameW(LPCWSTR filename, LPWSTR volumepathname, DWORD bu WCHAR cwdW[MAX_PATH]; /* the path was completely invalid */ - if (filename[0] == '\\') + if (filename[0] == '\\' && strncmpW(deviceprefixW, filename, strlenW(deviceprefixW)) != 0) { - /* NT-style paths fail */ + /* NT-style and device-style paths fail */ status = STATUS_OBJECT_NAME_INVALID; goto cleanup; } -- 1.9.1