diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-03-12 21:36:49 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-03-12 21:36:49 +0000 |
commit | 0dd3c0b05c4cd5efa124c7fe42ba7aac2965ddad (patch) | |
tree | e6e1eb55e0a787df1c768713bfca467439ec0217 /sh.c | |
parent | 0215375d37c9d7eecc4fd467d89060c2bb5016e2 (diff) | |
download | busybox-w32-0dd3c0b05c4cd5efa124c7fe42ba7aac2965ddad.tar.gz busybox-w32-0dd3c0b05c4cd5efa124c7fe42ba7aac2965ddad.tar.bz2 busybox-w32-0dd3c0b05c4cd5efa124c7fe42ba7aac2965ddad.zip |
A fix from Larry Doolittle for some nasty segfaults when sh.c tried to free a
corrupted cmd pointer, and where it would truncate a command line at the first
double space.
-Erik
git-svn-id: svn://busybox.net/trunk/busybox@2047 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'sh.c')
-rw-r--r-- | sh.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -970,10 +970,10 @@ static int expand_arguments(char *command) | |||
970 | { | 970 | { |
971 | 971 | ||
972 | int flags = GLOB_NOCHECK|GLOB_BRACE|GLOB_TILDE; | 972 | int flags = GLOB_NOCHECK|GLOB_BRACE|GLOB_TILDE; |
973 | char * tmpcmd; | 973 | char * tmpcmd, *cmd, *cmd_copy; |
974 | /* We need a clean copy, so strsep can mess up the copy while | 974 | /* We need a clean copy, so strsep can mess up the copy while |
975 | * we write stuff into the original (in a minute) */ | 975 | * we write stuff into the original (in a minute) */ |
976 | char * cmd = strdup(command); | 976 | cmd = cmd_copy = strdup(command); |
977 | *command = '\0'; | 977 | *command = '\0'; |
978 | for (tmpcmd = cmd; (tmpcmd = strsep(&cmd, " \t")) != NULL;) { | 978 | for (tmpcmd = cmd; (tmpcmd = strsep(&cmd, " \t")) != NULL;) { |
979 | if (*tmpcmd == '\0') | 979 | if (*tmpcmd == '\0') |
@@ -1006,7 +1006,7 @@ static int expand_arguments(char *command) | |||
1006 | globfree (&expand_result); | 1006 | globfree (&expand_result); |
1007 | } | 1007 | } |
1008 | } | 1008 | } |
1009 | free(cmd); | 1009 | free(cmd_copy); |
1010 | trim(command); | 1010 | trim(command); |
1011 | } | 1011 | } |
1012 | 1012 | ||