aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-10-29 19:46:40 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2015-10-29 19:46:40 +0100
commite2f32c02b149f5a128c634231a0ef12d03843967 (patch)
tree0acd6d9ebe1720ac40de5b847281104a57deb95d /shell
parent383b885ff7654dc0171b5c1eaa449bb1e1cfe8f0 (diff)
downloadbusybox-w32-e2f32c02b149f5a128c634231a0ef12d03843967.tar.gz
busybox-w32-e2f32c02b149f5a128c634231a0ef12d03843967.tar.bz2
busybox-w32-e2f32c02b149f5a128c634231a0ef12d03843967.zip
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>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 18c7ff523..8f0a5e0be 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -8878,14 +8878,15 @@ parse_command_args(char **argv, const char **path)
8878 for (;;) { 8878 for (;;) {
8879 cp = *++argv; 8879 cp = *++argv;
8880 if (!cp) 8880 if (!cp)
8881 return 0; 8881 return NULL;
8882 if (*cp++ != '-') 8882 if (*cp++ != '-')
8883 break; 8883 break;
8884 c = *cp++; 8884 c = *cp++;
8885 if (!c) 8885 if (!c)
8886 break; 8886 break;
8887 if (c == '-' && !*cp) { 8887 if (c == '-' && !*cp) {
8888 argv++; 8888 if (!*++argv)
8889 return NULL;
8889 break; 8890 break;
8890 } 8891 }
8891 do { 8892 do {
@@ -8895,7 +8896,7 @@ parse_command_args(char **argv, const char **path)
8895 break; 8896 break;
8896 default: 8897 default:
8897 /* run 'typecmd' for other options */ 8898 /* run 'typecmd' for other options */
8898 return 0; 8899 return NULL;
8899 } 8900 }
8900 c = *cp++; 8901 c = *cp++;
8901 } while (c); 8902 } while (c);