Module: wine Branch: master Commit: 4e5594546713a36ef02cf350ffd78fdd4132efa6 URL: https://gitlab.winehq.org/wine/wine/-/commit/4e5594546713a36ef02cf350ffd78fd...
Author: Paul Gofman pgofman@codeweavers.com Date: Thu Sep 28 19:23:41 2023 -0600
shell32: Handle long command line in execute_from_key().
---
dlls/shell32/shlexec.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c index 4b943d69637..b31f800e92a 100644 --- a/dlls/shell32/shlexec.c +++ b/dlls/shell32/shlexec.c @@ -965,7 +965,7 @@ static UINT_PTR execute_from_key(LPCWSTR key, LPCWSTR lpFile, WCHAR *env, LPCWST SHELL_ExecuteW32 execfunc, LPSHELLEXECUTEINFOW psei, LPSHELLEXECUTEINFOW psei_out) { - WCHAR cmd[256], param[1024], ddeexec[256]; + WCHAR cmd[256], parambuffer[1024], ddeexec[256], *param = parambuffer; LONG cmdlen = sizeof(cmd), ddeexeclen = sizeof(ddeexec); UINT_PTR retval = SE_ERR_NOASSOC; DWORD resultLen; @@ -987,9 +987,12 @@ static UINT_PTR execute_from_key(LPCWSTR key, LPCWSTR lpFile, WCHAR *env, LPCWST if (cmdlen >= ARRAY_SIZE(cmd)) cmdlen = ARRAY_SIZE(cmd) - 1; cmd[cmdlen] = '\0'; - SHELL_ArgifyW(param, ARRAY_SIZE(param), cmd, lpFile, psei->lpIDList, szCommandline, &resultLen); - if (resultLen > ARRAY_SIZE(param)) - ERR("Argify buffer not large enough, truncating\n"); + SHELL_ArgifyW(param, ARRAY_SIZE(parambuffer), cmd, lpFile, psei->lpIDList, szCommandline, &resultLen); + if (resultLen > ARRAY_SIZE(parambuffer)) + { + if ((param = malloc(resultLen * sizeof(*param)))) + SHELL_ArgifyW(param, resultLen, cmd, lpFile, psei->lpIDList, szCommandline, &resultLen); + } }
/* Get the parameters needed by the application @@ -1012,6 +1015,7 @@ static UINT_PTR execute_from_key(LPCWSTR key, LPCWSTR lpFile, WCHAR *env, LPCWST else WARN("Nothing appropriate found for %s\n", debugstr_w(key));
+ if (param != parambuffer) free(param); return retval; }