From 596921da0cf3765940d5ce6e5993f1b91c9c2cce Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sat, 24 Jun 2000 20:53:47 +0000 Subject: [PATCH] Make sure the cmdline passed to CreateProcessA is writeable (thanks to Peter Ganten ). --- include/process.h | 2 +- loader/module.c | 8 ++++++-- scheduler/process.c | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/process.h b/include/process.h index 06d6b2be30b..ea1994f14f2 100644 --- a/include/process.h +++ b/include/process.h @@ -152,7 +152,7 @@ extern void PROCESS_InitWine( int argc, char *argv[] ) WINE_NORETURN; extern void PROCESS_InitWinelib( int argc, char *argv[] ) WINE_NORETURN; extern PDB *PROCESS_IdToPDB( DWORD id ); extern void PROCESS_CallUserSignalProc( UINT uCode, HMODULE hModule ); -extern BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPCSTR cmd_line, LPCSTR env, +extern BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env, LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa, BOOL inherit, DWORD flags, STARTUPINFOA *startup, PROCESS_INFORMATION *info ); diff --git a/loader/module.c b/loader/module.c index a55837ae089..d8bbe6c495a 100644 --- a/loader/module.c +++ b/loader/module.c @@ -723,13 +723,17 @@ HINSTANCE WINAPI WinExec( LPCSTR lpCmdLine, UINT nCmdShow ) PROCESS_INFORMATION info; STARTUPINFOA startup; HINSTANCE hInstance; + char *cmdline; memset( &startup, 0, sizeof(startup) ); startup.cb = sizeof(startup); startup.dwFlags = STARTF_USESHOWWINDOW; startup.wShowWindow = nCmdShow; - if (CreateProcessA( NULL, (LPSTR)lpCmdLine, NULL, NULL, FALSE, + /* cmdline needs to be writeable for CreateProcess */ + if (!(cmdline = HEAP_strdupA( GetProcessHeap(), 0, lpCmdLine ))) return 0; + + if (CreateProcessA( NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info )) { /* Give 30 seconds to the app to come up */ @@ -745,7 +749,7 @@ HINSTANCE WINAPI WinExec( LPCSTR lpCmdLine, UINT nCmdShow ) FIXME("Strange error set by CreateProcess: %d\n", hInstance ); hInstance = 11; } - + HeapFree( GetProcessHeap(), 0, cmdline ); return hInstance; } diff --git a/scheduler/process.c b/scheduler/process.c index 0e30571083b..3334591c540 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -674,7 +674,7 @@ static void exec_wine_binary( char **argv, char **envp ) * * Fork and exec a new Unix process, checking for errors. */ -static int fork_and_exec( const char *filename, const char *cmdline, const char *env ) +static int fork_and_exec( const char *filename, char *cmdline, const char *env ) { int fd[2]; int pid, err; @@ -687,7 +687,7 @@ static int fork_and_exec( const char *filename, const char *cmdline, const char fcntl( fd[1], F_SETFD, 1 ); /* set close on exec */ if (!(pid = fork())) /* child */ { - char **argv = build_argv( (char *)cmdline, filename ? 0 : 2 ); + char **argv = build_argv( cmdline, filename ? 0 : 2 ); char **envp = build_envp( env ); close( fd[0] ); if (argv && envp) @@ -722,7 +722,7 @@ static int fork_and_exec( const char *filename, const char *cmdline, const char * file, and we exec a new copy of wine to load it; otherwise we * simply exec the specified filename as a Unix process. */ -BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPCSTR cmd_line, LPCSTR env, +BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env, LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa, BOOL inherit, DWORD flags, LPSTARTUPINFOA startup, LPPROCESS_INFORMATION info )