https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3199fdbd4430542384d49b...
commit 3199fdbd4430542384d49b32cf2dede02ff6bab4 Author: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org AuthorDate: Mon Jun 28 02:06:15 2021 +0200 Commit: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org CommitDate: Mon Jun 28 02:19:31 2021 +0200
[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. --- dll/win32/shlwapi/path.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/dll/win32/shlwapi/path.c b/dll/win32/shlwapi/path.c index f3149f35e58..fc698251cf2 100644 --- a/dll/win32/shlwapi/path.c +++ b/dll/win32/shlwapi/path.c @@ -40,7 +40,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(shell);
#ifdef __REACTOS__ + +#include <shlobj.h> +#include <shlwapi_undoc.h> + int WINAPI IsNetDrive(int drive); + #else
/* Get a function pointer from a DLL handle */ @@ -1127,17 +1132,32 @@ BOOL WINAPI PathFileExistsDefExtW(LPWSTR lpszPath,DWORD dwWhich) if (dwWhich) { LPCWSTR szExt = PathFindExtensionW(lpszPath); +#ifndef __REACTOS__ if (!*szExt || dwWhich & 0x40) +#else + if (!*szExt || dwWhich & WHICH_OPTIONAL) +#endif { size_t iChoose = 0; int iLen = lstrlenW(lpszPath); if (iLen > (MAX_PATH - 5)) return FALSE; +#ifndef __REACTOS__ while ( (dwWhich & 0x1) && pszExts[iChoose][0] ) +#else + while (pszExts[iChoose][0]) +#endif { +#ifdef __REACTOS__ + if (dwWhich & 0x1) + { +#endif lstrcpyW(lpszPath + iLen, pszExts[iChoose]); if (PathFileExistsW(lpszPath)) return TRUE; +#ifdef __REACTOS__ + } +#endif iChoose++; dwWhich >>= 1; }