kernel32: GetShortPathName should fail when called with a wildcard.

Signed-off-by: Dmitry Timoshkov <dmitry@baikal.ru>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Dmitry Timoshkov 2018-10-20 23:46:38 +03:00 committed by Alexandre Julliard
parent 9bc6068843
commit 3a78ec672a
2 changed files with 10 additions and 3 deletions

View File

@ -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] == ':' )
{

View File

@ -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);