diff options
author | Eric Andersen <andersen@codepoet.org> | 2001-03-12 21:36:49 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2001-03-12 21:36:49 +0000 |
commit | 4987bbf97924044c88007c45ee2674d97b93ad92 (patch) | |
tree | e6e1eb55e0a787df1c768713bfca467439ec0217 | |
parent | 5ec5415402ee6e4ae21e4a50c04360908325ba81 (diff) | |
download | busybox-4987bbf97924044c88007c45ee2674d97b93ad92.tar.gz |
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
-rw-r--r-- | lash.c | 6 | ||||
-rw-r--r-- | sh.c | 6 | ||||
-rw-r--r-- | shell/lash.c | 6 |
3 files changed, 9 insertions, 9 deletions
@@ -970,10 +970,10 @@ static int expand_arguments(char *command) { int flags = GLOB_NOCHECK|GLOB_BRACE|GLOB_TILDE; - char * tmpcmd; + char * tmpcmd, *cmd, *cmd_copy; /* We need a clean copy, so strsep can mess up the copy while * we write stuff into the original (in a minute) */ - char * cmd = strdup(command); + cmd = cmd_copy = strdup(command); *command = '\0'; for (tmpcmd = cmd; (tmpcmd = strsep(&cmd, " \t")) != NULL;) { if (*tmpcmd == '\0') @@ -1006,7 +1006,7 @@ static int expand_arguments(char *command) globfree (&expand_result); } } - free(cmd); + free(cmd_copy); trim(command); } @@ -970,10 +970,10 @@ static int expand_arguments(char *command) { int flags = GLOB_NOCHECK|GLOB_BRACE|GLOB_TILDE; - char * tmpcmd; + char * tmpcmd, *cmd, *cmd_copy; /* We need a clean copy, so strsep can mess up the copy while * we write stuff into the original (in a minute) */ - char * cmd = strdup(command); + cmd = cmd_copy = strdup(command); *command = '\0'; for (tmpcmd = cmd; (tmpcmd = strsep(&cmd, " \t")) != NULL;) { if (*tmpcmd == '\0') @@ -1006,7 +1006,7 @@ static int expand_arguments(char *command) globfree (&expand_result); } } - free(cmd); + free(cmd_copy); trim(command); } diff --git a/shell/lash.c b/shell/lash.c index d321c929b..67d6e4f51 100644 --- a/shell/lash.c +++ b/shell/lash.c @@ -970,10 +970,10 @@ static int expand_arguments(char *command) { int flags = GLOB_NOCHECK|GLOB_BRACE|GLOB_TILDE; - char * tmpcmd; + char * tmpcmd, *cmd, *cmd_copy; /* We need a clean copy, so strsep can mess up the copy while * we write stuff into the original (in a minute) */ - char * cmd = strdup(command); + cmd = cmd_copy = strdup(command); *command = '\0'; for (tmpcmd = cmd; (tmpcmd = strsep(&cmd, " \t")) != NULL;) { if (*tmpcmd == '\0') @@ -1006,7 +1006,7 @@ static int expand_arguments(char *command) globfree (&expand_result); } } - free(cmd); + free(cmd_copy); trim(command); } |