From: YeshunYe <yeyeshun@uniontech.com> If 'name' does not have a suffix, a suffix will be appended in find_exe_file. If 'name' contains spaces, it will result in an incorrect filename being concatenated. Signed-off-by: YeshunYe <yeyeshun@uniontech.com> --- dlls/kernel32/tests/process.c | 1 - dlls/kernelbase/process.c | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index a77e2f4f328..61c05e6ff0a 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -1170,7 +1170,6 @@ static void test_CommandLine(void) get_file_name(resfile); sprintf(buffer2, "\"%s \" process dump \"%s\"", buffer, resfile); ret = CreateProcessA(NULL, buffer2, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info); - todo_wine ok(ret, "CreateProcess (%s) failed : %ld\n", buffer, GetLastError()); if (info.hProcess) { diff --git a/dlls/kernelbase/process.c b/dlls/kernelbase/process.c index 3656e40280d..b6e48853f49 100644 --- a/dlls/kernelbase/process.c +++ b/dlls/kernelbase/process.c @@ -87,10 +87,20 @@ static WCHAR *get_file_name( WCHAR *cmdline, WCHAR *buffer, DWORD buflen ) if (cmdline[0] == '"' && (p = wcschr( cmdline + 1, '"' ))) { - int len = p - cmdline - 1; + int len; + /* trim spaces in quotes */ + const WCHAR* start = cmdline + 1; + const WCHAR* end = p - 1; + while (*end == ' ' && end > start) end--; + if (end < start) + { + SetLastError( ERROR_INVALID_PARAMETER ); + return ret; + } + len = end - start + 1; /* extract the quoted portion as file name */ if (!(name = RtlAllocateHeap( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return NULL; - memcpy( name, cmdline + 1, len * sizeof(WCHAR) ); + memcpy( name, start, len * sizeof(WCHAR) ); name[len] = 0; if (!find_exe_file( name, buffer, buflen )) goto done; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9882