Commit 596921da authored by Alexandre Julliard's avatar Alexandre Julliard

Make sure the cmdline passed to CreateProcessA is writeable (thanks to

Peter Ganten <peter@ganten.org>).
parent b4905d22
......@@ -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 );
......
......@@ -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;
}
......
......@@ -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 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment