Module: wine Branch: master Commit: 77fa0502fa220c5578fff93f7e53a92f50817089 URL: https://source.winehq.org/git/wine.git/?a=commit;h=77fa0502fa220c5578fff93f7...
Author: Piotr Caban piotr@codeweavers.com Date: Fri May 4 22:39:49 2018 +0200
kernel32: Fix CreateProcess behavior when batch script command contains '"' characters.
Signed-off-by: Piotr Caban piotr@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/kernel32/process.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c index 47f1cfb..df3426b 100644 --- a/dlls/kernel32/process.c +++ b/dlls/kernel32/process.c @@ -2211,7 +2211,8 @@ static BOOL create_cmd_process( LPCWSTR filename, LPWSTR cmd_line, LPVOID env, L
{ static const WCHAR comspecW[] = {'C','O','M','S','P','E','C',0}; - static const WCHAR slashcW[] = {' ','/','c',' ',0}; + static const WCHAR slashscW[] = {' ','/','s','/','c',' ',0}; + static const WCHAR quotW[] = {'"',0}; WCHAR comspec[MAX_PATH]; WCHAR *newcmdline; BOOL ret; @@ -2219,12 +2220,14 @@ static BOOL create_cmd_process( LPCWSTR filename, LPWSTR cmd_line, LPVOID env, L if (!GetEnvironmentVariableW( comspecW, comspec, sizeof(comspec)/sizeof(WCHAR) )) return FALSE; if (!(newcmdline = HeapAlloc( GetProcessHeap(), 0, - (strlenW(comspec) + 4 + strlenW(cmd_line) + 1) * sizeof(WCHAR)))) + (strlenW(comspec) + 7 + strlenW(cmd_line) + 2) * sizeof(WCHAR)))) return FALSE;
strcpyW( newcmdline, comspec ); - strcatW( newcmdline, slashcW ); + strcatW( newcmdline, slashscW ); + strcatW( newcmdline, quotW ); strcatW( newcmdline, cmd_line ); + strcatW( newcmdline, quotW ); ret = CreateProcessW( comspec, newcmdline, psa, tsa, inherit, flags, env, cur_dir, startup, info ); HeapFree( GetProcessHeap(), 0, newcmdline );