Skip to content

Commit 448fcbc

Browse files
PietJankbaljulliard
authored andcommitted
shell32: Remove trailing spaces in SHELL_execute.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56940
1 parent b5a4c2f commit 448fcbc

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

dlls/shell32/shlexec.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -1670,10 +1670,13 @@ static BOOL SHELL_execute( LPSHELLEXECUTEINFOW sei, SHELL_ExecuteW32 execfunc )
16701670
wszApplicationName[len-2] = '\0';
16711671
TRACE("wszApplicationName=%s\n",debugstr_w(wszApplicationName));
16721672
} else {
1673-
DWORD l = lstrlenW(sei_tmp.lpFile)+1;
1674-
if(l > dwApplicationNameLen) dwApplicationNameLen = l+1;
1675-
wszApplicationName = malloc(dwApplicationNameLen * sizeof(WCHAR));
1676-
memcpy(wszApplicationName, sei_tmp.lpFile, l*sizeof(WCHAR));
1673+
/* remove trailing spaces */
1674+
WCHAR *buf = wcsdup(sei->lpFile), *end = buf + wcslen( buf ) - 1;
1675+
while (end >= buf && *end == ' ') *end-- = 0;
1676+
1677+
len = lstrlenW(buf)+1;
1678+
if(len > dwApplicationNameLen) dwApplicationNameLen = len+1;
1679+
wszApplicationName = buf;
16771680
}
16781681

16791682
wszParameters = parametersBuffer;

dlls/shell32/tests/shlexec.c

+9
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,15 @@ static void test_lpFile_parsed(void)
11661166
NULL, "\"%TMPDIR%\\simple.shlexec\"", NULL, NULL, NULL);
11671167
okShell(rc > 32 || broken(rc == SE_ERR_FNF) /* Win95/NT4 */,
11681168
"failed: rc=%Iu\n", rc);
1169+
/* test lpfile + trailing space */
1170+
rc=shell_execute_ex(SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI,
1171+
NULL, "%TMPDIR%\\simple.shlexec ", NULL, NULL, NULL);
1172+
okShell(rc > 32, "failed: rc=%Iu\n", rc);
1173+
/* test lpfile + leading space */
1174+
rc=shell_execute_ex(SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI,
1175+
NULL, " %TMPDIR%\\simple.shlexec", NULL, NULL, NULL);
1176+
okShell(rc == SE_ERR_FNF, "failed: rc=%Iu\n", rc);
1177+
11691178
}
11701179

11711180
typedef struct

0 commit comments

Comments
 (0)