[PATCH 2/3] kernel32: GetShortPathName should fail when called with a wildcard.
Dmitry Timoshkov
dmitry at baikal.ru
Sat Oct 20 15:46:38 CDT 2018
Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
---
dlls/kernel32/path.c | 11 ++++++++++-
dlls/kernel32/tests/path.c | 2 --
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
index 7dcb937430..a9db7e8cdf 100644
--- a/dlls/kernel32/path.c
+++ b/dlls/kernel32/path.c
@@ -45,6 +45,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(file);
static int path_safe_mode = -1; /* path mode set by SetSearchPathMode */
+static const WCHAR wildcardsW[] = {'*','?',0};
+
/* check if a file name is for an executable file (.exe or .com) */
static inline BOOL is_executable( const WCHAR *name )
{
@@ -445,7 +447,7 @@ DWORD WINAPI GetShortPathNameW( LPCWSTR longpath, LPWSTR shortpath, DWORD shortl
WIN32_FIND_DATAW wfd;
HANDLE goit;
- TRACE("%s\n", debugstr_w(longpath));
+ TRACE("%s,%p,%u\n", debugstr_w(longpath), shortpath, shortlen);
if (!longpath)
{
@@ -474,6 +476,13 @@ DWORD WINAPI GetShortPathNameW( LPCWSTR longpath, LPWSTR shortpath, DWORD shortl
sp = lp = 4;
}
+ if (strpbrkW(longpath + lp, wildcardsW))
+ {
+ HeapFree(GetProcessHeap(), 0, tmpshortpath);
+ SetLastError(ERROR_INVALID_NAME);
+ return 0;
+ }
+
/* check for drive letter */
if (longpath[lp] != '/' && longpath[lp + 1] == ':' )
{
diff --git a/dlls/kernel32/tests/path.c b/dlls/kernel32/tests/path.c
index 5ca69d3b3c..f0cfb4d43c 100644
--- a/dlls/kernel32/tests/path.c
+++ b/dlls/kernel32/tests/path.c
@@ -1477,9 +1477,7 @@ static void test_GetShortPathNameW(void)
lstrcpyW(ptr, wildW);
SetLastError(0xdeadbeef);
length = GetShortPathNameW( path, short_path, ARRAY_SIZE( short_path ) );
-todo_wine
ok(!length, "GetShortPathNameW should fail\n");
-todo_wine
ok(GetLastError() == ERROR_INVALID_NAME, "wrong error %d\n", GetLastError());
lstrcpyW(ptr, a_bcdeW);
--
2.17.1
More information about the wine-devel
mailing list