Rebase against da5151fd54c2679b9cd10a7a4d2933f727266bf5.

This commit is contained in:
Sebastian Lackner 2015-06-23 16:38:54 +02:00
parent 094635f160
commit ec9b8ec16d
11 changed files with 20 additions and 899 deletions

View File

@ -253,7 +253,7 @@ for more details.*
* Support for FileFsFullSizeInformation information class
* ~~Support for GdipCreateRegionRgnData~~ ([Wine Bug #34843](https://bugs.winehq.org/show_bug.cgi?id=34843))
* Support for GetFinalPathNameByHandle ([Wine Bug #34851](https://bugs.winehq.org/show_bug.cgi?id=34851))
* Support for GetVolumePathName
* ~~Support for GetVolumePathName~~
* Support for H264 DXVA2 GPU video decoding through vaapi
* Support for ID3DXFont::DrawTextA/W ([Wine Bug #24754](https://bugs.winehq.org/show_bug.cgi?id=24754))
* Support for ID3DXSkinInfoImpl_UpdateSkinnedMesh ([Wine Bug #32572](https://bugs.winehq.org/show_bug.cgi?id=32572))

1
debian/changelog vendored
View File

@ -25,6 +25,7 @@ wine-staging (1.7.46) UNRELEASED; urgency=low
upstream).
* Removed patch to fix possible use-after-free in wineserver device IPR code
(accepted upstream).
* Removed patches to implement GetVolumePathName (accepted upstream).
* Removed patch to fix linking against libunwind on Linux (fixed upstream).
-- Sebastian Lackner <sebastian@fds-team.de> Sun, 14 Jun 2015 09:15:50 +0200

View File

@ -1,190 +0,0 @@
From 6c8b09bb431e70a3667fd791737491f027641615 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@wine-staging.com>
Date: Wed, 17 Jun 2015 19:28:39 -0600
Subject: kernel32: Implement GetVolumePathName.
---
dlls/kernel32/tests/volume.c | 3 --
dlls/kernel32/volume.c | 121 ++++++++++++++++++++++++++++++++++++++-----
2 files changed, 107 insertions(+), 17 deletions(-)
diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c
index e934dee..2243da9 100644
--- a/dlls/kernel32/tests/volume.c
+++ b/dlls/kernel32/tests/volume.c
@@ -649,15 +649,12 @@ static void test_GetVolumePathNameA(void)
volume[0] = '\0';
ret = pGetVolumePathNameA(pathC1, volume, sizeof(volume));
ok(ret, "expected success\n");
-todo_wine
ok(!strcmp(expected, volume) || broken(!strcasecmp(expected, volume)) /* <=XP */,
"expected name '%s', returned '%s'\n", expected, volume);
volume[0] = '\0';
ret = pGetVolumePathNameA(pathC2, volume, sizeof(volume));
-todo_wine
ok(ret, "expected success\n");
-todo_wine
ok(!strcmp(expected, volume), "expected name '%s', returned '%s'\n", expected, volume);
/* test an invalid path */
diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c
index d06dd05..4720cb4 100644
--- a/dlls/kernel32/volume.c
+++ b/dlls/kernel32/volume.c
@@ -1792,7 +1792,7 @@ BOOL WINAPI GetVolumePathNameA(LPCSTR filename, LPSTR volumepathname, DWORD bufl
BOOL ret;
WCHAR *filenameW = NULL, *volumeW = NULL;
- FIXME("(%s, %p, %d), stub!\n", debugstr_a(filename), volumepathname, buflen);
+ TRACE("(%s, %p, %d)\n", debugstr_a(filename), volumepathname, buflen);
if (filename && !(filenameW = FILE_name_AtoW( filename, FALSE )))
return FALSE;
@@ -1808,12 +1808,27 @@ BOOL WINAPI GetVolumePathNameA(LPCSTR filename, LPSTR volumepathname, DWORD bufl
/***********************************************************************
* GetVolumePathNameW (KERNEL32.@)
+ *
+ * This routine is intended to find the most basic path on the same filesystem
+ * for any particular path name. Since we can have very complicated drive/path
+ * relationships on Unix systems, due to symbolic links, the safest way to
+ * handle this is to start with the full path and work our way back folder by
+ * folder unil we find a folder on a different drive (or run out of folders).
*/
BOOL WINAPI GetVolumePathNameW(LPCWSTR filename, LPWSTR volumepathname, DWORD buflen)
{
- const WCHAR *p = filename;
+ const WCHAR ntprefixW[] = { '\\','\\','?','\\',0 };
+ const WCHAR fallbackpathW[] = { 'C',':','\\',0 };
+ NTSTATUS status = STATUS_SUCCESS;
+ WCHAR *volumenameW = NULL, *c;
+ int pos, last_pos, stop_pos;
+ UNICODE_STRING nt_name;
+ ANSI_STRING unix_name;
+ BOOL first_run = TRUE;
+ dev_t search_dev = 0;
+ struct stat st;
- FIXME("(%s, %p, %d), stub!\n", debugstr_w(filename), volumepathname, buflen);
+ TRACE("(%s, %p, %d)\n", debugstr_w(filename), volumepathname, buflen);
if (!filename || !volumepathname || !buflen)
{
@@ -1821,24 +1836,102 @@ BOOL WINAPI GetVolumePathNameW(LPCWSTR filename, LPWSTR volumepathname, DWORD bu
return FALSE;
}
- if (p && tolowerW(p[0]) >= 'a' && tolowerW(p[0]) <= 'z' && p[1] ==':' && p[2] == '\\')
+ last_pos = pos = strlenW( filename );
+ /* allocate enough memory for searching the path (need room for a slash and a NULL terminator) */
+ if (!(volumenameW = HeapAlloc( GetProcessHeap(), 0, (pos + 2) * sizeof(WCHAR) )))
{
- if (buflen < 4)
+ SetLastError( ERROR_NOT_ENOUGH_MEMORY );
+ return FALSE;
+ }
+ strcpyW( volumenameW, filename );
+ stop_pos = 0;
+ /* stop searching slashes early for NT-type and nearly NT-type paths */
+ if (strncmpW(ntprefixW, filename, strlenW(ntprefixW)) == 0)
+ stop_pos = strlenW(ntprefixW)-1;
+ else if (strncmpW(ntprefixW, filename, 2) == 0)
+ stop_pos = 2;
+
+ do
+ {
+ volumenameW[pos+0] = '\\';
+ volumenameW[pos+1] = '\0';
+ if (!RtlDosPathNameToNtPathName_U( volumenameW, &nt_name, NULL, NULL ))
+ goto cleanup;
+ volumenameW[pos] = '\0';
+ status = wine_nt_to_unix_file_name( &nt_name, &unix_name, FILE_OPEN, FALSE );
+ RtlFreeUnicodeString( &nt_name );
+ if (status == STATUS_SUCCESS)
{
- SetLastError(ERROR_FILENAME_EXCED_RANGE);
- return FALSE;
+ if (stat( unix_name.Buffer, &st ) != 0)
+ {
+ RtlFreeAnsiString( &unix_name );
+ status = STATUS_OBJECT_NAME_INVALID;
+ goto cleanup;
+ }
+ if (first_run)
+ {
+ first_run = FALSE;
+ search_dev = st.st_dev;
+ }
+ else if (st.st_dev != search_dev)
+ {
+ /* folder is on a new filesystem, return the last folder */
+ RtlFreeAnsiString( &unix_name );
+ break;
+ }
}
- volumepathname[0] = p[0];
- volumepathname[1] = ':';
- volumepathname[2] = '\\';
- volumepathname[3] = 0;
- return TRUE;
+ RtlFreeAnsiString( &unix_name );
+ last_pos = pos;
+ c = strrchrW( volumenameW, '\\' );
+ if (c != NULL)
+ pos = c-volumenameW;
+ } while (c != NULL && pos > stop_pos);
+
+ if (status != STATUS_SUCCESS)
+ {
+ /* the path was completely invalid */
+ if (filename[0] == '\\')
+ {
+ /* NT-style paths fail */
+ status = STATUS_OBJECT_NAME_INVALID;
+ goto cleanup;
+ }
+
+ /* DOS-style paths revert to C:\ (anything not beginning with a slash) */
+ last_pos = strlenW(fallbackpathW) - 1; /* points to \\ */
+ filename = fallbackpathW;
+ status = STATUS_SUCCESS;
}
- SetLastError(ERROR_INVALID_NAME);
- return FALSE;
+ if (last_pos + 1 <= buflen)
+ {
+ WCHAR *p;
+ memcpy(volumepathname, filename, last_pos * sizeof(WCHAR));
+ if (last_pos + 2 <= buflen) volumepathname[last_pos++] = '\\';
+ volumepathname[last_pos] = '\0';
+
+ /* Normalize path */
+ for (p = volumepathname; *p; p++) if (*p == '/') *p = '\\';
+
+ /* DOS-style paths always return upper-case drive letters */
+ if (volumepathname[1] == ':')
+ volumepathname[0] = toupper(volumepathname[0]);
+
+ TRACE("Successfully translated path %s to mount-point %s\n",
+ debugstr_w(filename), debugstr_w(volumepathname));
+ }
+ else
+ status = STATUS_NAME_TOO_LONG;
+
+cleanup:
+ HeapFree( GetProcessHeap(), 0, volumenameW );
+
+ if (status != STATUS_SUCCESS)
+ SetLastError( RtlNtStatusToDosError(status) );
+ return (status == STATUS_SUCCESS);
}
+
/***********************************************************************
* GetVolumePathNamesForVolumeNameA (KERNEL32.@)
*/
--
1.9.1

View File

@ -1,170 +0,0 @@
From fc911ce59b14c352982aaf2b5b91edb976642451 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@wine-staging.com>
Date: Wed, 17 Jun 2015 19:28:54 -0600
Subject: kernel32: Convert GetVolumePathName tests into a list.
---
dlls/kernel32/tests/volume.c | 137 +++++++++++++++++++++++--------------------
1 file changed, 74 insertions(+), 63 deletions(-)
diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c
index 2243da9..2bb2603 100644
--- a/dlls/kernel32/tests/volume.c
+++ b/dlls/kernel32/tests/volume.c
@@ -591,79 +591,90 @@ static void test_disk_extents(void)
static void test_GetVolumePathNameA(void)
{
- BOOL ret;
- char volume[MAX_PATH];
- char expected[] = "C:\\", pathC1[] = "C:\\", pathC2[] = "C::";
+ char volume_path[MAX_PATH];
+ struct {
+ const char *file_name;
+ const char *path_name;
+ DWORD path_len;
+ DWORD error;
+ DWORD broken_error;
+ } test_paths[] = {
+ { /* test 0: NULL parameters, 0 output length */
+ NULL, NULL, 0,
+ ERROR_INVALID_PARAMETER, 0xdeadbeef /* winxp */
+ },
+ { /* test 1: empty input, NULL output, 0 output length */
+ "", NULL, 0,
+ ERROR_INVALID_PARAMETER, 0xdeadbeef /* winxp */
+ },
+ { /* test 2: valid input, NULL output, 0 output length */
+ "C:\\", NULL, 0,
+ ERROR_INVALID_PARAMETER, ERROR_FILENAME_EXCED_RANGE /* winxp */
+ },
+ { /* test 3: valid input, valid output, 0 output length */
+ "C:\\", "C:\\", 0,
+ ERROR_INVALID_PARAMETER, ERROR_FILENAME_EXCED_RANGE /* winxp */
+ },
+ { /* test 4: valid input, valid output, 1 output length */
+ "C:\\", "C:\\", 1,
+ ERROR_FILENAME_EXCED_RANGE, NO_ERROR
+ },
+ { /* test 5: valid input, valid output, valid output length */
+ "C:\\", "C:\\", sizeof(volume_path),
+ NO_ERROR, NO_ERROR
+ },
+ { /* test 6: lowercase input, uppercase output, valid output length */
+ "c:\\", "C:\\", sizeof(volume_path),
+ NO_ERROR, NO_ERROR
+ },
+ { /* test 7: poor quality input, valid output, valid output length */
+ "C::", "C:\\", sizeof(volume_path),
+ NO_ERROR, NO_ERROR
+ },
+ { /* test 8: really bogus input, valid output, 1 output length */
+ "\\\\$$$", "C:\\", 1,
+ ERROR_INVALID_NAME, ERROR_FILENAME_EXCED_RANGE
+ },
+ };
+ BOOL ret, success;
DWORD error;
+ UINT i;
+ /* GetVolumePathNameA is not present before w2k */
if (!pGetVolumePathNameA)
{
win_skip("required functions not found\n");
return;
}
- SetLastError( 0xdeadbeef );
- ret = pGetVolumePathNameA(NULL, NULL, 0);
- error = GetLastError();
- ok(!ret, "expected failure\n");
- ok(error == ERROR_INVALID_PARAMETER
- || broken( error == 0xdeadbeef) /* <=XP */,
- "expected ERROR_INVALID_PARAMETER got %u\n", error);
-
- SetLastError( 0xdeadbeef );
- ret = pGetVolumePathNameA("", NULL, 0);
- error = GetLastError();
- ok(!ret, "expected failure\n");
- ok(error == ERROR_INVALID_PARAMETER
- || broken( error == 0xdeadbeef) /* <=XP */,
- "expected ERROR_INVALID_PARAMETER got %u\n", error);
+ for (i=0; i<sizeof(test_paths)/sizeof(test_paths[0]); i++)
+ {
+ char *output = (test_paths[i].path_name != NULL ? volume_path : NULL);
+ BOOL expected_ret = test_paths[i].error == NO_ERROR ? TRUE : FALSE;
- SetLastError( 0xdeadbeef );
- ret = pGetVolumePathNameA(pathC1, NULL, 0);
- error = GetLastError();
- ok(!ret, "expected failure\n");
- ok(error == ERROR_INVALID_PARAMETER
- || broken(error == ERROR_FILENAME_EXCED_RANGE) /* <=XP */,
- "expected ERROR_INVALID_PARAMETER got %u\n", error);
+ volume_path[0] = 0;
+ SetLastError( 0xdeadbeef );
+ ret = pGetVolumePathNameA( test_paths[i].file_name, output, test_paths[i].path_len );
+ error = GetLastError();
+ ok(ret == expected_ret, "GetVolumePathName test %d %s unexpectedly.\n",
+ i, test_paths[i].error == NO_ERROR ? "failed" : "succeeded");
- SetLastError( 0xdeadbeef );
- ret = pGetVolumePathNameA(pathC1, volume, 0);
- error = GetLastError();
- ok(!ret, "expected failure\n");
- ok(error == ERROR_INVALID_PARAMETER
- || broken(error == ERROR_FILENAME_EXCED_RANGE ) /* <=XP */,
- "expected ERROR_INVALID_PARAMETER got %u\n", error);
-
- SetLastError( 0xdeadbeef );
- ret = pGetVolumePathNameA(pathC1, volume, 1);
- error = GetLastError();
- ok(!ret, "expected failure\n");
- ok(error == ERROR_FILENAME_EXCED_RANGE, "expected ERROR_FILENAME_EXCED_RANGE got %u\n", error);
-
- volume[0] = '\0';
- ret = pGetVolumePathNameA(pathC1, volume, sizeof(volume));
- ok(ret, "expected success\n");
- ok(!strcmp(expected, volume), "expected name '%s', returned '%s'\n", pathC1, volume);
-
- pathC1[0] = tolower(pathC1[0]);
- volume[0] = '\0';
- ret = pGetVolumePathNameA(pathC1, volume, sizeof(volume));
- ok(ret, "expected success\n");
- ok(!strcmp(expected, volume) || broken(!strcasecmp(expected, volume)) /* <=XP */,
- "expected name '%s', returned '%s'\n", expected, volume);
-
- volume[0] = '\0';
- ret = pGetVolumePathNameA(pathC2, volume, sizeof(volume));
- ok(ret, "expected success\n");
- ok(!strcmp(expected, volume), "expected name '%s', returned '%s'\n", expected, volume);
-
- /* test an invalid path */
- SetLastError( 0xdeadbeef );
- ret = pGetVolumePathNameA("\\\\$$$", volume, 1);
- error = GetLastError();
- ok(!ret, "expected failure\n");
- ok(error == ERROR_INVALID_NAME || broken(ERROR_FILENAME_EXCED_RANGE) /* <=2000 */,
- "expected ERROR_INVALID_NAME got %u\n", error);
+ if (ret)
+ {
+ /* If we succeeded then make sure the path is correct */
+ success = (strcmp( volume_path, test_paths[i].path_name ) == 0)
+ || broken(strcasecmp( volume_path, test_paths[i].path_name ) == 0) /* XP */;
+ ok(success, "GetVolumePathName test %d unexpectedly returned path %s (expected %s).\n",
+ i, volume_path, test_paths[i].path_name);
+ }
+ else
+ {
+ /* On success Windows always returns ERROR_MORE_DATA, so only worry about failure */
+ success = (error == test_paths[i].error || broken(error == test_paths[i].broken_error));
+ ok(success, "GetVolumePathName test %d unexpectedly returned error 0x%x (expected 0x%x).\n",
+ i, error, test_paths[i].error);
+ }
+ }
}
static void test_GetVolumePathNamesForVolumeNameA(void)
--
1.9.1

View File

@ -1,69 +0,0 @@
From 4e662a9f24b82213cd5744e7281c3a5056050e80 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@wine-staging.com>
Date: Wed, 17 Jun 2015 19:29:16 -0600
Subject: kernel32: Add a bunch more GetVolumePathName tests.
---
dlls/kernel32/tests/volume.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c
index 2bb2603..3eb7fed 100644
--- a/dlls/kernel32/tests/volume.c
+++ b/dlls/kernel32/tests/volume.c
@@ -635,6 +635,34 @@ static void test_GetVolumePathNameA(void)
"\\\\$$$", "C:\\", 1,
ERROR_INVALID_NAME, ERROR_FILENAME_EXCED_RANGE
},
+ { /* test 9: a reasonable DOS path that is guaranteed to exist */
+ "C:\\windows\\system32", "C:\\", sizeof(volume_path),
+ NO_ERROR, NO_ERROR
+ },
+ { /* test 10: a reasonable DOS path that shouldn't exist */
+ "C:\\windows\\system32\\AnInvalidFolder", "C:\\", sizeof(volume_path),
+ NO_ERROR, NO_ERROR
+ },
+ { /* test 11: a reasonable NT-converted DOS path that shouldn't exist */
+ "\\\\?\\C:\\AnInvalidFolder", "\\\\?\\C:\\", sizeof(volume_path),
+ NO_ERROR, NO_ERROR
+ },
+ { /* test 12: an unreasonable NT-converted DOS path */
+ "\\\\?\\InvalidDrive:\\AnInvalidFolder", "\\\\?\\InvalidDrive:\\" /* win2k, winxp */,
+ sizeof(volume_path),
+ ERROR_INVALID_NAME, NO_ERROR
+ },
+ { /* test 13: an unreasonable NT volume path */
+ "\\\\?\\Volume{00000000-00-0000-0000-000000000000}\\AnInvalidFolder",
+ "\\\\?\\Volume{00000000-00-0000-0000-000000000000}\\" /* win2k, winxp */,
+ sizeof(volume_path),
+ ERROR_INVALID_NAME, NO_ERROR
+ },
+ { /* test 14: an unreasonable NT-ish path */
+ "\\\\ReallyBogus\\InvalidDrive:\\AnInvalidFolder",
+ "\\\\ReallyBogus\\InvalidDrive:\\" /* win2k, winxp */, sizeof(volume_path),
+ ERROR_INVALID_NAME, NO_ERROR
+ },
};
BOOL ret, success;
DWORD error;
@@ -649,6 +677,7 @@ static void test_GetVolumePathNameA(void)
for (i=0; i<sizeof(test_paths)/sizeof(test_paths[0]); i++)
{
+ BOOL broken_ret = test_paths[i].broken_error == NO_ERROR ? TRUE : FALSE;
char *output = (test_paths[i].path_name != NULL ? volume_path : NULL);
BOOL expected_ret = test_paths[i].error == NO_ERROR ? TRUE : FALSE;
@@ -656,7 +685,8 @@ static void test_GetVolumePathNameA(void)
SetLastError( 0xdeadbeef );
ret = pGetVolumePathNameA( test_paths[i].file_name, output, test_paths[i].path_len );
error = GetLastError();
- ok(ret == expected_ret, "GetVolumePathName test %d %s unexpectedly.\n",
+ ok(ret == expected_ret || broken(ret == broken_ret),
+ "GetVolumePathName test %d %s unexpectedly.\n",
i, test_paths[i].error == NO_ERROR ? "failed" : "succeeded");
if (ret)
--
1.9.1

View File

@ -1,64 +0,0 @@
From c46f7883a62e17b59e10d3bdabf5e0e26a989009 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@wine-staging.com>
Date: Tue, 16 Jun 2015 08:17:23 -0600
Subject: kernel32: Handle semi-DOS paths in GetVolumePathName.
---
dlls/kernel32/tests/volume.c | 8 ++++++++
dlls/kernel32/volume.c | 14 ++++++++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c
index 3eb7fed..5b117b8 100644
--- a/dlls/kernel32/tests/volume.c
+++ b/dlls/kernel32/tests/volume.c
@@ -663,6 +663,14 @@ static void test_GetVolumePathNameA(void)
"\\\\ReallyBogus\\InvalidDrive:\\" /* win2k, winxp */, sizeof(volume_path),
ERROR_INVALID_NAME, NO_ERROR
},
+ { /* test 15: poor quality input, valid output, valid output length, different drive */
+ "D::", "D:\\", sizeof(volume_path),
+ NO_ERROR, NO_ERROR
+ },
+ { /* test 16: unused drive letter */
+ "M::", "C:\\", 4,
+ ERROR_FILE_NOT_FOUND, ERROR_MORE_DATA
+ },
};
BOOL ret, success;
DWORD error;
diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c
index 4720cb4..3eef540 100644
--- a/dlls/kernel32/volume.c
+++ b/dlls/kernel32/volume.c
@@ -1818,7 +1818,7 @@ BOOL WINAPI GetVolumePathNameA(LPCSTR filename, LPSTR volumepathname, DWORD bufl
BOOL WINAPI GetVolumePathNameW(LPCWSTR filename, LPWSTR volumepathname, DWORD buflen)
{
const WCHAR ntprefixW[] = { '\\','\\','?','\\',0 };
- const WCHAR fallbackpathW[] = { 'C',':','\\',0 };
+ WCHAR fallbackpathW[] = { 'C',':','\\',0 };
NTSTATUS status = STATUS_SUCCESS;
WCHAR *volumenameW = NULL, *c;
int pos, last_pos, stop_pos;
@@ -1897,7 +1897,17 @@ BOOL WINAPI GetVolumePathNameW(LPCWSTR filename, LPWSTR volumepathname, DWORD bu
goto cleanup;
}
- /* DOS-style paths revert to C:\ (anything not beginning with a slash) */
+ /* DOS-style paths (anything not beginning with a slash) have fallback replies */
+ if (filename[1] == ':')
+ {
+ /* if the path is semi-sane (X:) then use the given drive letter (if it is mounted) */
+ fallbackpathW[0] = filename[0];
+ if (!isalpha(filename[0]) || GetDriveTypeW( fallbackpathW ) == DRIVE_NO_ROOT_DIR)
+ {
+ status = STATUS_OBJECT_NAME_NOT_FOUND;
+ goto cleanup;
+ }
+ }
last_pos = strlenW(fallbackpathW) - 1; /* points to \\ */
filename = fallbackpathW;
status = STATUS_SUCCESS;
--
1.9.1

View File

@ -1,99 +0,0 @@
From f58ffbfac9dd899e4a546759ede241dfd7163eae Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@wine-staging.com>
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<sizeof(test_paths)/sizeof(test_paths[0]); i++)
{
BOOL broken_ret = test_paths[i].broken_error == NO_ERROR ? TRUE : FALSE;
@@ -699,11 +710,14 @@ static void test_GetVolumePathNameA(void)
if (ret)
{
+ char path_name[MAX_PATH];
+
+ ExpandEnvironmentStringsA( test_paths[i].path_name, path_name, MAX_PATH);
/* If we succeeded then make sure the path is correct */
- success = (strcmp( volume_path, test_paths[i].path_name ) == 0)
- || broken(strcasecmp( volume_path, test_paths[i].path_name ) == 0) /* XP */;
+ success = (strcmp( volume_path, path_name ) == 0)
+ || broken(strcasecmp( volume_path, path_name ) == 0) /* XP */;
ok(success, "GetVolumePathName test %d unexpectedly returned path %s (expected %s).\n",
- i, volume_path, test_paths[i].path_name);
+ i, volume_path, path_name);
}
else
{
diff --git a/dlls/kernel32/volume.c b/dlls/kernel32/volume.c
index 3eef540..e135967 100644
--- a/dlls/kernel32/volume.c
+++ b/dlls/kernel32/volume.c
@@ -1889,6 +1889,8 @@ BOOL WINAPI GetVolumePathNameW(LPCWSTR filename, LPWSTR volumepathname, DWORD bu
if (status != STATUS_SUCCESS)
{
+ WCHAR cwdW[MAX_PATH];
+
/* the path was completely invalid */
if (filename[0] == '\\')
{
@@ -1908,6 +1910,16 @@ BOOL WINAPI GetVolumePathNameW(LPCWSTR filename, LPWSTR volumepathname, DWORD bu
goto cleanup;
}
}
+ else if (GetCurrentDirectoryW( sizeof(cwdW), cwdW ))
+ {
+ /* if the path is completely bogus then revert to the drive of the working directory */
+ fallbackpathW[0] = cwdW[0];
+ }
+ else
+ {
+ status = STATUS_OBJECT_NAME_INVALID;
+ goto cleanup;
+ }
last_pos = strlenW(fallbackpathW) - 1; /* points to \\ */
filename = fallbackpathW;
status = STATUS_SUCCESS;
--
1.9.1

View File

@ -1,56 +0,0 @@
From 33c65845c7841e2766d25ec370d6723a6dc5c38b Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@wine-staging.com>
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

View File

@ -1,203 +0,0 @@
From ba80811571531adf3c09736b42dd400e0269abea Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Tue, 2 Sep 2014 05:23:37 +0200
Subject: kernel32/tests: Add a lot of picky GetVolumePathName tests.
---
dlls/kernel32/tests/volume.c | 142 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 142 insertions(+)
diff --git a/dlls/kernel32/tests/volume.c b/dlls/kernel32/tests/volume.c
index 4349ec4..67aa852 100644
--- a/dlls/kernel32/tests/volume.c
+++ b/dlls/kernel32/tests/volume.c
@@ -54,6 +54,7 @@ static UINT (WINAPI *pGetLogicalDriveStringsA)(UINT,LPSTR);
static UINT (WINAPI *pGetLogicalDriveStringsW)(UINT,LPWSTR);
static BOOL (WINAPI *pGetVolumeInformationA)(LPCSTR, LPSTR, DWORD, LPDWORD, LPDWORD, LPDWORD, LPSTR, DWORD);
static BOOL (WINAPI *pGetVolumePathNameA)(LPCSTR, LPSTR, DWORD);
+static BOOL (WINAPI *pGetVolumePathNameW)(LPWSTR, LPWSTR, DWORD);
static BOOL (WINAPI *pGetVolumePathNamesForVolumeNameA)(LPCSTR, LPSTR, DWORD, LPDWORD);
static BOOL (WINAPI *pGetVolumePathNamesForVolumeNameW)(LPCWSTR, LPWSTR, DWORD, LPDWORD);
@@ -683,6 +684,94 @@ static void test_GetVolumePathNameA(void)
"\\??\\ReallyBogus", "%CurrentDrive%\\", sizeof(volume_path),
NO_ERROR, NO_ERROR
},
+ { /* test 20 */
+ "C:", "C:", 2,
+ ERROR_FILENAME_EXCED_RANGE, NO_ERROR
+ },
+ { /* test 21 */
+ "C:", "C:", 3,
+ NO_ERROR, ERROR_FILENAME_EXCED_RANGE
+ },
+ { /* test 22 */
+ "C:\\", "C:", 2,
+ ERROR_FILENAME_EXCED_RANGE, NO_ERROR
+ },
+ { /* test 23 */
+ "C:\\", "C:", 3,
+ NO_ERROR, ERROR_FILENAME_EXCED_RANGE
+ },
+ { /* test 24 */
+ "C::", "C:", 2,
+ ERROR_FILENAME_EXCED_RANGE, NO_ERROR
+ },
+ { /* test 25 */
+ "C::", "C:", 3,
+ NO_ERROR, ERROR_FILENAME_EXCED_RANGE
+ },
+ { /* test 26 */
+ "C::", "C:\\", 4,
+ NO_ERROR, ERROR_MORE_DATA
+ },
+ { /* test 27 */
+ "C:\\windows\\system32\\AnInvalidFolder", "C:", 3,
+ NO_ERROR, ERROR_FILENAME_EXCED_RANGE
+ },
+ { /* test 28 */
+ "\\\\?\\C:\\AnInvalidFolder", "\\\\?\\C:", 3,
+ ERROR_FILENAME_EXCED_RANGE, NO_ERROR
+ },
+ { /* test 29 */
+ "\\\\?\\C:\\AnInvalidFolder", "\\\\?\\C:", 6,
+ ERROR_FILENAME_EXCED_RANGE, NO_ERROR
+ },
+ { /* test 30 */
+ "\\\\?\\C:\\AnInvalidFolder", "\\\\?\\C:", 7,
+ NO_ERROR, ERROR_FILENAME_EXCED_RANGE
+ },
+ { /* test 31 */
+ "\\\\?\\c:\\AnInvalidFolder", "\\\\?\\c:", 7,
+ NO_ERROR, ERROR_FILENAME_EXCED_RANGE
+ },
+ { /* test 32 */
+ "C:/", "C:\\", 4,
+ NO_ERROR, ERROR_MORE_DATA
+ },
+ { /* test 33 */
+ "M:/", "", 4,
+ ERROR_FILE_NOT_FOUND, ERROR_MORE_DATA
+ },
+ { /* test 34 */
+ "C:ABC:DEF:\\AnInvalidFolder", "C:\\", 4,
+ NO_ERROR, ERROR_MORE_DATA
+ },
+ { /* test 35 */
+ "?:ABC:DEF:\\AnInvalidFolder", "?:\\" /* win2k, winxp */, sizeof(volume_path),
+ ERROR_FILE_NOT_FOUND, NO_ERROR
+ },
+ { /* test 36 */
+ "relative/path", "%CurrentDrive%\\", sizeof(volume_path),
+ NO_ERROR, NO_ERROR
+ },
+ { /* test 37 */
+ "/unix-style/absolute/path", "%CurrentDrive%\\", sizeof(volume_path),
+ NO_ERROR, NO_ERROR
+ },
+ { /* test 38 */
+ "\\??\\C:\\NonExistent", "%CurrentDrive%\\", sizeof(volume_path),
+ NO_ERROR, NO_ERROR
+ },
+ { /* test 39 */
+ "\\??\\M:\\NonExistent", "%CurrentDrive%\\", sizeof(volume_path),
+ NO_ERROR, NO_ERROR
+ },
+ { /* test 40 */
+ "somefile:def", "%CurrentDrive%\\", sizeof(volume_path),
+ NO_ERROR, NO_ERROR
+ },
+ { /* test 41 */
+ "s:omefile", "S:\\" /* win2k, winxp */, sizeof(volume_path),
+ ERROR_FILE_NOT_FOUND, NO_ERROR
+ },
};
BOOL ret, success;
DWORD error;
@@ -709,6 +798,9 @@ static void test_GetVolumePathNameA(void)
BOOL expected_ret = test_paths[i].error == NO_ERROR ? TRUE : FALSE;
volume_path[0] = 0;
+ if (test_paths[i].path_len < sizeof(volume_path))
+ volume_path[ test_paths[i].path_len ] = 0x11;
+
SetLastError( 0xdeadbeef );
ret = pGetVolumePathNameA( test_paths[i].file_name, output, test_paths[i].path_len );
error = GetLastError();
@@ -734,9 +826,57 @@ static void test_GetVolumePathNameA(void)
ok(success, "GetVolumePathName test %d unexpectedly returned error 0x%x (expected 0x%x).\n",
i, error, test_paths[i].error);
}
+
+ if (test_paths[i].path_len < sizeof(volume_path))
+ ok(volume_path[ test_paths[i].path_len ] == 0x11,
+ "GetVolumePathName test %d corrupted byte after end of buffer.\n", i);
}
}
+static void test_GetVolumePathNameW(void)
+{
+ static WCHAR drive_c1[] = {'C',':',0};
+ static WCHAR drive_c2[] = {'C',':','\\',0};
+ WCHAR volume_path[MAX_PATH];
+ BOOL ret;
+
+ if (!pGetVolumePathNameW)
+ {
+ win_skip("required functions not found\n");
+ return;
+ }
+
+ volume_path[0] = 0;
+ volume_path[1] = 0x11;
+ ret = pGetVolumePathNameW( drive_c1, volume_path, 1 );
+ ok(!ret, "GetVolumePathNameW test succeeded unexpectedly.\n");
+ ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE, "GetVolumePathNameW unexpectedly returned error 0x%x (expected 0x%x).\n",
+ GetLastError(), ERROR_FILENAME_EXCED_RANGE);
+ ok(volume_path[1] == 0x11, "GetVolumePathW corrupted byte after end of buffer.\n");
+
+ volume_path[0] = 0;
+ volume_path[2] = 0x11;
+ ret = pGetVolumePathNameW( drive_c1, volume_path, 2 );
+ ok(!ret, "GetVolumePathNameW test succeeded unexpectedly.\n");
+ ok(GetLastError() == ERROR_FILENAME_EXCED_RANGE, "GetVolumePathNameW unexpectedly returned error 0x%x (expected 0x%x).\n",
+ GetLastError(), ERROR_FILENAME_EXCED_RANGE);
+ ok(volume_path[2] == 0x11, "GetVolumePathW corrupted byte after end of buffer.\n");
+
+ volume_path[0] = 0;
+ volume_path[3] = 0x11;
+ ret = pGetVolumePathNameW( drive_c1, volume_path, 3 );
+ ok(ret, "GetVolumePathNameW test failed unexpectedly.\n");
+ ok(memcmp(volume_path, drive_c1, sizeof(drive_c1)) == 0, "GetVolumePathNameW unexpectedly returned wrong path.\n");
+ ok(volume_path[3] == 0x11, "GetVolumePathW corrupted byte after end of buffer.\n");
+
+ volume_path[0] = 0;
+ volume_path[4] = 0x11;
+ ret = pGetVolumePathNameW( drive_c1, volume_path, 4 );
+ ok(ret, "GetVolumePathNameW test failed unexpectedly.\n");
+ ok(memcmp(volume_path, drive_c2, sizeof(drive_c2)) == 0, "GetVolumePathNameW unexpectedly returned wrong path.\n");
+ ok(volume_path[4] == 0x11, "GetVolumePathW corrupted byte after end of buffer.\n");
+}
+
static void test_GetVolumePathNamesForVolumeNameA(void)
{
BOOL ret;
@@ -1076,6 +1216,7 @@ START_TEST(volume)
pGetLogicalDriveStringsW = (void *) GetProcAddress(hdll, "GetLogicalDriveStringsW");
pGetVolumeInformationA = (void *) GetProcAddress(hdll, "GetVolumeInformationA");
pGetVolumePathNameA = (void *) GetProcAddress(hdll, "GetVolumePathNameA");
+ pGetVolumePathNameW = (void *) GetProcAddress(hdll, "GetVolumePathNameW");
pGetVolumePathNamesForVolumeNameA = (void *) GetProcAddress(hdll, "GetVolumePathNamesForVolumeNameA");
pGetVolumePathNamesForVolumeNameW = (void *) GetProcAddress(hdll, "GetVolumePathNamesForVolumeNameW");
@@ -1083,6 +1224,7 @@ START_TEST(volume)
test_define_dos_deviceA();
test_FindFirstVolume();
test_GetVolumePathNameA();
+ test_GetVolumePathNameW();
test_GetVolumeNameForVolumeMountPointA();
test_GetVolumeNameForVolumeMountPointW();
test_GetLogicalDriveStringsA();
--
1.9.1

View File

@ -1 +0,0 @@
Fixes: Support for GetVolumePathName

View File

@ -55,7 +55,7 @@ version()
echo "Copyright (C) 2014-2015 the Wine Staging project authors."
echo ""
echo "Patchset to be applied on upstream Wine:"
echo " commit af55ae137965512a1635e69b8f41849114f60012"
echo " commit da5151fd54c2679b9cd10a7a4d2933f727266bf5"
echo ""
}
@ -135,7 +135,6 @@ patch_enable_all ()
enable_kernel32_GetFinalPathNameByHandle="$1"
enable_kernel32_GetLogicalProcessorInformationEx="$1"
enable_kernel32_GetNumaProcessorNode="$1"
enable_kernel32_GetVolumePathName="$1"
enable_kernel32_InsertMode="$1"
enable_kernel32_Named_Pipe="$1"
enable_kernel32_NeedCurrentDirectoryForExePath="$1"
@ -484,9 +483,6 @@ patch_enable ()
kernel32-GetNumaProcessorNode)
enable_kernel32_GetNumaProcessorNode="$2"
;;
kernel32-GetVolumePathName)
enable_kernel32_GetVolumePathName="$2"
;;
kernel32-InsertMode)
enable_kernel32_InsertMode="$2"
;;
@ -3075,30 +3071,6 @@ if test "$enable_kernel32_GetNumaProcessorNode" -eq 1; then
) >> "$patchlist"
fi
# Patchset kernel32-GetVolumePathName
# |
# | Modified files:
# | * dlls/kernel32/tests/volume.c, dlls/kernel32/volume.c
# |
if test "$enable_kernel32_GetVolumePathName" -eq 1; then
patch_apply kernel32-GetVolumePathName/0001-kernel32-Implement-GetVolumePathName.patch
patch_apply kernel32-GetVolumePathName/0002-kernel32-Convert-GetVolumePathName-tests-into-a-list.patch
patch_apply kernel32-GetVolumePathName/0003-kernel32-Add-a-bunch-more-GetVolumePathName-tests.patch
patch_apply kernel32-GetVolumePathName/0004-kernel32-Handle-semi-DOS-paths-in-GetVolumePathName.patch
patch_apply kernel32-GetVolumePathName/0005-kernel32-Handle-bogus-DOS-paths-in-GetVolumePathName.patch
patch_apply kernel32-GetVolumePathName/0006-kernel32-Handle-device-paths-in-GetVolumePathName.patch
patch_apply kernel32-GetVolumePathName/0007-kernel32-tests-Add-a-lot-of-picky-GetVolumePathName-.patch
(
echo '+ { "Erich E. Hoover", "kernel32: Implement GetVolumePathName.", 1 },';
echo '+ { "Erich E. Hoover", "kernel32: Convert GetVolumePathName tests into a list.", 1 },';
echo '+ { "Erich E. Hoover", "kernel32: Add a bunch more GetVolumePathName tests.", 1 },';
echo '+ { "Erich E. Hoover", "kernel32: Handle semi-DOS paths in GetVolumePathName.", 1 },';
echo '+ { "Erich E. Hoover", "kernel32: Handle bogus DOS paths in GetVolumePathName.", 1 },';
echo '+ { "Erich E. Hoover", "kernel32: Handle device paths in GetVolumePathName.", 1 },';
echo '+ { "Sebastian Lackner", "kernel32/tests: Add a lot of picky GetVolumePathName tests.", 1 },';
) >> "$patchlist"
fi
# Patchset kernel32-InsertMode
# |
# | Modified files:
@ -5055,15 +5027,15 @@ if test "$enable_wined3d_CSMT_Helper" -eq 1; then
) >> "$patchlist"
fi
# Patchset wined3d-UnhandledBlendFactor
# Patchset wined3d-resource_check_usage
# |
# | Modified files:
# | * dlls/wined3d/state.c
# | * dlls/wined3d/resource.c
# |
if test "$enable_wined3d_UnhandledBlendFactor" -eq 1; then
patch_apply wined3d-UnhandledBlendFactor/0001-wined3d-Silence-repeated-Unhandled-blend-factor-0-me.patch
if test "$enable_wined3d_resource_check_usage" -eq 1; then
patch_apply wined3d-resource_check_usage/0001-wined3d-Silence-repeated-resource_check_usage-FIXME.patch
(
echo '+ { "Sebastian Lackner", "wined3d: Silence repeated '\''Unhandled blend factor 0'\'' messages.", 1 },';
echo '+ { "Erich E. Hoover", "wined3d: Silence repeated resource_check_usage FIXME.", 2 },';
) >> "$patchlist"
fi
@ -5079,18 +5051,6 @@ if test "$enable_wined3d_wined3d_swapchain_present" -eq 1; then
) >> "$patchlist"
fi
# Patchset wined3d-resource_check_usage
# |
# | Modified files:
# | * dlls/wined3d/resource.c
# |
if test "$enable_wined3d_resource_check_usage" -eq 1; then
patch_apply wined3d-resource_check_usage/0001-wined3d-Silence-repeated-resource_check_usage-FIXME.patch
(
echo '+ { "Erich E. Hoover", "wined3d: Silence repeated resource_check_usage FIXME.", 2 },';
) >> "$patchlist"
fi
# Patchset wined3d-Multisampling
# |
# | This patchset fixes the following Wine bugs:
@ -5140,6 +5100,18 @@ if test "$enable_wined3d_Revert_PixelFormat" -eq 1; then
) >> "$patchlist"
fi
# Patchset wined3d-UnhandledBlendFactor
# |
# | Modified files:
# | * dlls/wined3d/state.c
# |
if test "$enable_wined3d_UnhandledBlendFactor" -eq 1; then
patch_apply wined3d-UnhandledBlendFactor/0001-wined3d-Silence-repeated-Unhandled-blend-factor-0-me.patch
(
echo '+ { "Sebastian Lackner", "wined3d: Silence repeated '\''Unhandled blend factor 0'\'' messages.", 1 },';
) >> "$patchlist"
fi
# Patchset wined3d-CSMT_Main
# |
# | This patchset fixes the following Wine bugs: