Commit 71de71c3 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Remove the limit on the length of the command line.

parent 5cbd491b
...@@ -101,12 +101,25 @@ static void license(void) ...@@ -101,12 +101,25 @@ static void license(void)
fatal_string(STRING_LICENSE); fatal_string(STRING_LICENSE);
} }
static char *build_args( int argc, char **argv )
{
int i, len = 1;
char *ret, *p;
for (i = 0; i < argc; i++ )
len += strlen(argv[i]) + 1;
ret = HeapAlloc( GetProcessHeap(), 0, len );
for (i = 0, p = ret; i < argc; i++ )
p += sprintf(p, " %s", argv[i]);
return ret;
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char arguments[MAX_PATH];
char *p;
SHELLEXECUTEINFO sei; SHELLEXECUTEINFO sei;
int argi; char *args;
int i;
memset(&sei, 0, sizeof(sei)); memset(&sei, 0, sizeof(sei));
sei.cbSize = sizeof(sei); sei.cbSize = sizeof(sei);
...@@ -119,24 +132,24 @@ int main(int argc, char *argv[]) ...@@ -119,24 +132,24 @@ int main(int argc, char *argv[])
* flags start with /, are case insensitive, * flags start with /, are case insensitive,
* and may be run together in same word. * and may be run together in same word.
*/ */
for (argi=1; argi<argc; argi++) { for (i=1; i<argc; i++) {
int ci; int ci;
if (argv[argi][0] != '/') if (argv[i][0] != '/')
break; break;
/* Handle all options in this word */ /* Handle all options in this word */
for (ci=0; argv[argi][ci]; ) { for (ci=0; argv[i][ci]; ) {
/* Skip slash */ /* Skip slash */
ci++; ci++;
switch(argv[argi][ci]) { switch(argv[i][ci]) {
case 'l': case 'l':
case 'L': case 'L':
license(); license();
break; /* notreached */ break; /* notreached */
case 'm': case 'm':
case 'M': case 'M':
if (argv[argi][ci+1] == 'a' || argv[argi][ci+1] == 'A') if (argv[i][ci+1] == 'a' || argv[i][ci+1] == 'A')
sei.nShow = SW_SHOWMAXIMIZED; sei.nShow = SW_SHOWMAXIMIZED;
else else
sei.nShow = SW_SHOWMINIMIZED; sei.nShow = SW_SHOWMINIMIZED;
...@@ -150,30 +163,28 @@ int main(int argc, char *argv[]) ...@@ -150,30 +163,28 @@ int main(int argc, char *argv[])
sei.fMask |= SEE_MASK_NOCLOSEPROCESS; sei.fMask |= SEE_MASK_NOCLOSEPROCESS;
break; break;
default: default:
printf("Option '%s' not recognized\n", argv[argi]+ci-1); printf("Option '%s' not recognized\n", argv[i]+ci-1);
usage(); usage();
} }
/* Skip to next slash */ /* Skip to next slash */
while (argv[argi][ci] && (argv[argi][ci] != '/')) while (argv[i][ci] && (argv[i][ci] != '/'))
ci++; ci++;
} }
} }
if (argi == argc) if (i == argc)
usage(); usage();
sei.lpFile = argv[argi++]; sei.lpFile = argv[i++];
/* FIXME - prone to overflow */
arguments[0] = 0;
for (p = arguments; argi < argc; argi++)
p += sprintf(p, " %s", argv[argi]);
sei.lpParameters = arguments; args = build_args( argc - i, &argv[i] );
sei.lpParameters = args;
if (!ShellExecuteEx(&sei)) if (!ShellExecuteEx(&sei))
fatal_string_error(STRING_EXECFAIL, GetLastError()); fatal_string_error(STRING_EXECFAIL, GetLastError());
HeapFree( GetProcessHeap(), 0, args );
if (sei.fMask & SEE_MASK_NOCLOSEPROCESS) { if (sei.fMask & SEE_MASK_NOCLOSEPROCESS) {
DWORD exitcode; DWORD exitcode;
DWORD waitcode; DWORD waitcode;
......
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