shell32: Don't return argified string in FindExecutable
André Hentschel
nerv at dawncrow.de
Sun Mar 20 16:10:35 CDT 2016
Signed-off-by: André Hentschel <nerv at dawncrow.de>
---
This fixes* 29979 which was better explained in https://bugs.winehq.org/show_bug.cgi?id=23283#c2
*) At least it makes the application bug as invisible as on windows for short enough executable strings
dlls/shell32/shlexec.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c
index 5fcbe03..6fc20cc 100644
--- a/dlls/shell32/shlexec.c
+++ b/dlls/shell32/shlexec.c
@@ -561,7 +561,7 @@ static UINT SHELL_FindExecutableByVerb(LPCWSTR lpVerb, LPWSTR key, LPWSTR classn
* on the operation)
*/
static UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpVerb,
- LPWSTR lpResult, int resultLen, LPWSTR key, WCHAR **env, LPITEMIDLIST pidl, LPCWSTR args)
+ LPWSTR lpResult, int resultLen, LPWSTR key, WCHAR **env, LPITEMIDLIST pidl, LPCWSTR args, BOOL exec_only)
{
static const WCHAR wWindows[] = {'w','i','n','d','o','w','s',0};
static const WCHAR wPrograms[] = {'p','r','o','g','r','a','m','s',0};
@@ -698,10 +698,15 @@ static UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpVerb,
if (retval > 32)
{
- DWORD finishedLen;
- SHELL_ArgifyW(lpResult, resultLen, command, xlpFile, pidl, args, &finishedLen);
- if (finishedLen > resultLen)
- ERR("Argify buffer not large enough.. truncated\n");
+ if (exec_only)
+ lstrcpynW(lpResult, command, resultLen);
+ else
+ {
+ DWORD finishedLen;
+ SHELL_ArgifyW(lpResult, resultLen, command, xlpFile, pidl, args, &finishedLen);
+ if (finishedLen > resultLen)
+ ERR("Argify buffer not large enough.. truncated\n");
+ }
/* Remove double quotation marks and command line arguments */
if (*lpResult == '"')
@@ -1100,7 +1105,7 @@ HINSTANCE WINAPI FindExecutableW(LPCWSTR lpFile, LPCWSTR lpDirectory, LPWSTR lpR
SetCurrentDirectoryW(lpDirectory);
}
- retval = SHELL_FindExecutable(lpDirectory, lpFile, wszOpen, lpResult, MAX_PATH, NULL, NULL, NULL, NULL);
+ retval = SHELL_FindExecutable(lpDirectory, lpFile, wszOpen, lpResult, MAX_PATH, NULL, NULL, NULL, NULL, TRUE);
TRACE("returning %s\n", debugstr_w(lpResult));
if (lpDirectory)
@@ -1790,7 +1795,7 @@ static BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
/* Else, try to find the executable */
wcmd[0] = '\0';
- retval = SHELL_FindExecutable(sei_tmp.lpDirectory, lpFile, sei_tmp.lpVerb, wcmd, wcmdLen, wszKeyname, &env, sei_tmp.lpIDList, sei_tmp.lpParameters);
+ retval = SHELL_FindExecutable(sei_tmp.lpDirectory, lpFile, sei_tmp.lpVerb, wcmd, wcmdLen, wszKeyname, &env, sei_tmp.lpIDList, sei_tmp.lpParameters, FALSE);
if (retval > 32) /* Found */
{
retval = SHELL_quote_and_execute( wcmd, wszParameters, wszKeyname,
@@ -1809,7 +1814,7 @@ static BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
{
retval = SHELL_FindExecutable( sei_tmp.lpDirectory, wExplorer,
wszOpen, wExec, MAX_PATH,
- NULL, &env, NULL, NULL );
+ NULL, &env, NULL, NULL, FALSE );
if (retval > 32)
{
strcpyW(lpQuotedFile, wQuote);
--
1.9.1
More information about the wine-patches
mailing list