ash: fix command -- crash

busybox sh -c 'command --' segfaults because parse_command_args
returns a pointer to a null pointer.

Based on commit 18071c7 from git://git.kernel.org/pub/scm/utils/dash/dash.git
by Gerrit Pape.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2015-10-29 19:46:40 +01:00
parent 383b885ff7
commit e2f32c02b1

View File

@ -8878,14 +8878,15 @@ parse_command_args(char **argv, const char **path)
for (;;) { for (;;) {
cp = *++argv; cp = *++argv;
if (!cp) if (!cp)
return 0; return NULL;
if (*cp++ != '-') if (*cp++ != '-')
break; break;
c = *cp++; c = *cp++;
if (!c) if (!c)
break; break;
if (c == '-' && !*cp) { if (c == '-' && !*cp) {
argv++; if (!*++argv)
return NULL;
break; break;
} }
do { do {
@ -8895,7 +8896,7 @@ parse_command_args(char **argv, const char **path)
break; break;
default: default:
/* run 'typecmd' for other options */ /* run 'typecmd' for other options */
return 0; return NULL;
} }
c = *cp++; c = *cp++;
} while (c); } while (c);