summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2015-10-29 19:46:40 +0100
committerDenys Vlasenko2015-10-29 19:46:40 +0100
commite2f32c02b149f5a128c634231a0ef12d03843967 (patch)
tree0acd6d9ebe1720ac40de5b847281104a57deb95d
parent383b885ff7654dc0171b5c1eaa449bb1e1cfe8f0 (diff)
downloadbusybox-e2f32c02b149f5a128c634231a0ef12d03843967.zip
busybox-e2f32c02b149f5a128c634231a0ef12d03843967.tar.gz
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>
-rw-r--r--shell/ash.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 18c7ff5..8f0a5e0 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -8878,14 +8878,15 @@ parse_command_args(char **argv, const char **path)
for (;;) {
cp = *++argv;
if (!cp)
- return 0;
+ return NULL;
if (*cp++ != '-')
break;
c = *cp++;
if (!c)
break;
if (c == '-' && !*cp) {
- argv++;
+ if (!*++argv)
+ return NULL;
break;
}
do {
@@ -8895,7 +8896,7 @@ parse_command_args(char **argv, const char **path)
break;
default:
/* run 'typecmd' for other options */
- return 0;
+ return NULL;
}
c = *cp++;
} while (c);