mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 19:42:57 +00:00
[SHLWAPI] Fix a trivial bug in PathFileExistsDefExtW() that seems to exist since 16+ years in Wine.
Suppose dwFlags == 1 | 4 (i.e. skipping the flag 2). Then the while-loop would only run once, because at the second iteration (after dwWhich >>= 1; has been executed once), dwWhich value == 2, but dwWhich & 0x1 == 0, which makes the while-loop condition false. Instead the loop should run, but the handling of the extension should be skipped.
This commit is contained in:
parent
8ec3580123
commit
3199fdbd44
1 changed files with 20 additions and 0 deletions
|
@ -40,7 +40,12 @@
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
||||||
|
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
|
|
||||||
|
#include <shlobj.h>
|
||||||
|
#include <shlwapi_undoc.h>
|
||||||
|
|
||||||
int WINAPI IsNetDrive(int drive);
|
int WINAPI IsNetDrive(int drive);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* Get a function pointer from a DLL handle */
|
/* Get a function pointer from a DLL handle */
|
||||||
|
@ -1127,17 +1132,32 @@ BOOL WINAPI PathFileExistsDefExtW(LPWSTR lpszPath,DWORD dwWhich)
|
||||||
if (dwWhich)
|
if (dwWhich)
|
||||||
{
|
{
|
||||||
LPCWSTR szExt = PathFindExtensionW(lpszPath);
|
LPCWSTR szExt = PathFindExtensionW(lpszPath);
|
||||||
|
#ifndef __REACTOS__
|
||||||
if (!*szExt || dwWhich & 0x40)
|
if (!*szExt || dwWhich & 0x40)
|
||||||
|
#else
|
||||||
|
if (!*szExt || dwWhich & WHICH_OPTIONAL)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
size_t iChoose = 0;
|
size_t iChoose = 0;
|
||||||
int iLen = lstrlenW(lpszPath);
|
int iLen = lstrlenW(lpszPath);
|
||||||
if (iLen > (MAX_PATH - 5))
|
if (iLen > (MAX_PATH - 5))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
#ifndef __REACTOS__
|
||||||
while ( (dwWhich & 0x1) && pszExts[iChoose][0] )
|
while ( (dwWhich & 0x1) && pszExts[iChoose][0] )
|
||||||
|
#else
|
||||||
|
while (pszExts[iChoose][0])
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
if (dwWhich & 0x1)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
lstrcpyW(lpszPath + iLen, pszExts[iChoose]);
|
lstrcpyW(lpszPath + iLen, pszExts[iChoose]);
|
||||||
if (PathFileExistsW(lpszPath))
|
if (PathFileExistsW(lpszPath))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
}
|
||||||
|
#endif
|
||||||
iChoose++;
|
iChoose++;
|
||||||
dwWhich >>= 1;
|
dwWhich >>= 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue