Skip to content

Commit e5a6b0f

Browse files
[SHELL32] SHELL_ArgifyW(): don't use SearchPathW() for receiving a path to a file (reactos#7605)
Get rid from bogus SearchPathW() call, which is marked as most likely not needed in the comment above (by Wine). Simply get a length of the file name and use the file name directly instead, with checking for its validity too. Similarly as it's done for other cases. That call seems actually not needed because it is already done using SearchPathW() in another parts of the code in this file, before calling SHELL_ArgifyW(). Fixes another heap corruption when trying to login via OAuth menthod in SpotifyXP 2.0.3 Beta (nightly build). The previous commit did not fix the bug fully, as I discovered it later. CORE-19953
1 parent 02032b7 commit e5a6b0f

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

dll/win32/shell32/shlexec.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,9 @@ static void ParseTildeEffect(PWSTR &res, LPCWSTR &args, DWORD &len, DWORD &used,
197197

198198
static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR* lpFile, LPITEMIDLIST pidl, LPCWSTR args, DWORD* out_len, const WCHAR* lpDir)
199199
{
200-
WCHAR xlpFile[1024];
201200
BOOL done = FALSE;
202201
BOOL found_p1 = FALSE;
203202
PWSTR res = out;
204-
PCWSTR cmd;
205203
DWORD used = 0;
206204
bool tildeEffect = false;
207205

@@ -279,20 +277,14 @@ static BOOL SHELL_ArgifyW(WCHAR* out, DWORD len, const WCHAR* fmt, const WCHAR*
279277
break;
280278

281279
case '1':
282-
if (!done || (*fmt == '1'))
280+
if ((!done || (*fmt == '1')) && lpFile)
283281
{
284-
/*FIXME Is the call to SearchPathW() really needed? We already have separated out the parameter string in args. */
285-
if (SearchPathW(lpDir, lpFile, L".exe", ARRAY_SIZE(xlpFile), xlpFile, NULL))
286-
cmd = xlpFile;
287-
else
288-
cmd = lpFile;
289-
290-
SIZE_T cmdlen = wcslen(cmd);
291-
used += cmdlen;
282+
SIZE_T filelen = wcslen(lpFile);
283+
used += filelen;
292284
if (used < len)
293285
{
294-
wcscpy(res, cmd);
295-
res += cmdlen;
286+
wcscpy(res, lpFile);
287+
res += filelen;
296288
}
297289
}
298290
found_p1 = TRUE;

0 commit comments

Comments
 (0)