From: "Erich E. Hoover" Subject: [PATCH 5/8] kernel32: Handle bogus DOS paths in GetVolumePathName. Message-Id: Date: Thu, 18 Jun 2015 19:16:47 -0600 Paths that are not NT and not even close to DOS don't actually fail catastrophically. Even though MSDN suggests that it returns the boot drive in this case, my tests on the testbot indicate that it returns the drive of the current working directory. From f988a64b010748972d38af5cb0fa15dbacc14b7d Mon Sep 17 00:00:00 2001 From: "Erich E. Hoover" Date: Mon, 15 Jun 2015 22:20:03 -0600 Subject: kernel32: Handle bogus DOS paths in GetVolumePathName. --- dlls/kernel32/tests/volume.c | 22 ++++++++++++++++++---- dlls/kernel32/volume.c | 12 ++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c index 5b117b8..7ed55d7 100644 --- a/dlls/kernel32/tests/volume.c +++ b/dlls/kernel32/tests/volume.c @@ -591,7 +591,7 @@ static void test_disk_extents(void) static void test_GetVolumePathNameA(void) { - char volume_path[MAX_PATH]; + char volume_path[MAX_PATH], cwd[MAX_PATH]; struct { const char *file_name; const char *path_name; @@ -671,6 +671,10 @@ static void test_GetVolumePathNameA(void) "M::", "C:\\", 4, ERROR_FILE_NOT_FOUND, ERROR_MORE_DATA }, + { /* test 17: an unreasonable DOS path */ + "InvalidDrive:\\AnInvalidFolder", "%CurrentDrive%\\", sizeof(volume_path), + NO_ERROR, NO_ERROR + }, }; BOOL ret, success; DWORD error; @@ -683,6 +687,13 @@ static void test_GetVolumePathNameA(void) return; } + /* Obtain the drive of the working directory */ + ret = GetCurrentDirectoryA( sizeof(cwd), cwd ); + ok( ret, "Failed to obtain the current working directory.\n" ); + cwd[2] = 0; + ret = SetEnvironmentVariableA( "CurrentDrive", cwd ); + ok( ret, "Failed to set an environment variable for the current working drive.\n" ); + for (i=0; i