Commit 7096384d authored by Andreas Mohr's avatar Andreas Mohr Committed by Alexandre Julliard

Fixed WinExec16 to handle quoted filenames correctly.

parent 72140b02
......@@ -720,35 +720,60 @@ BOOL WINAPI GetBinaryTypeW( LPCWSTR lpApplicationName, LPDWORD lpBinaryType )
*/
HINSTANCE16 WINAPI WinExec16( LPCSTR lpCmdLine, UINT16 nCmdShow )
{
LPCSTR p = NULL;
LPCSTR p, args = NULL;
LPCSTR name_beg, name_end;
LPSTR name, cmdline;
int len;
int arglen;
HINSTANCE16 ret;
char buffer[MAX_PATH];
if ( ( *lpCmdLine == '"' ) && ( p = strchr ( lpCmdLine+1, '"' ) ) )
p = strchr ( p, ' ' );
if (*lpCmdLine == '"') /* has to be only one and only at beginning ! */
{
name_beg = lpCmdLine+1;
p = strchr ( lpCmdLine+1, '"' );
if (p)
{
name_end = p;
args = strchr ( p, ' ' );
}
else /* yes, even valid with trailing '"' missing */
name_end = lpCmdLine+strlen(lpCmdLine);
}
else
p = strchr( lpCmdLine, ' ' );
if ( p )
{
if (!(name = HeapAlloc( GetProcessHeap(), 0, p - lpCmdLine + 1 )))
name_beg = lpCmdLine;
args = strchr( lpCmdLine, ' ' );
name_end = args ? args : lpCmdLine+strlen(lpCmdLine);
}
if ((name_beg == lpCmdLine) && (!args))
{ /* just use the original cmdline string as file name */
name = (LPSTR)lpCmdLine;
}
else
{
if (!(name = HeapAlloc( GetProcessHeap(), 0, name_end - name_beg + 1 )))
return ERROR_NOT_ENOUGH_MEMORY;
memcpy( name, lpCmdLine, p - lpCmdLine );
name[p - lpCmdLine] = 0;
p++;
len = strlen(p);
cmdline = SEGPTR_ALLOC( len + 2 );
cmdline[0] = (BYTE)len;
strcpy( cmdline + 1, p );
memcpy( name, name_beg, name_end - name_beg );
name[name_end - name_beg] = '\0';
}
if (args)
{
args++;
arglen = strlen(args);
cmdline = SEGPTR_ALLOC( 2 + arglen );
cmdline[0] = (BYTE)arglen;
strcpy( cmdline + 1, args );
}
else
{
name = (LPSTR)lpCmdLine;
cmdline = SEGPTR_ALLOC(2);
cmdline = SEGPTR_ALLOC( 2 );
cmdline[0] = cmdline[1] = 0;
}
TRACE("name: %s, cmdline: %.*s\n", name, cmdline[0], &cmdline[1]);
if (SearchPathA( NULL, name, ".exe", sizeof(buffer), buffer, NULL ))
{
LOADPARAMS16 params;
......
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