aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-03-12 21:36:49 +0000
committerEric Andersen <andersen@codepoet.org>2001-03-12 21:36:49 +0000
commit4987bbf97924044c88007c45ee2674d97b93ad92 (patch)
treee6e1eb55e0a787df1c768713bfca467439ec0217
parent5ec5415402ee6e4ae21e4a50c04360908325ba81 (diff)
downloadbusybox-w32-4987bbf97924044c88007c45ee2674d97b93ad92.tar.gz
busybox-w32-4987bbf97924044c88007c45ee2674d97b93ad92.tar.bz2
busybox-w32-4987bbf97924044c88007c45ee2674d97b93ad92.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
-rw-r--r--lash.c6
-rw-r--r--sh.c6
-rw-r--r--shell/lash.c6
3 files changed, 9 insertions, 9 deletions
diff --git a/lash.c b/lash.c
index d321c929b..67d6e4f51 100644
--- a/lash.c
+++ b/lash.c
@@ -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
diff --git a/sh.c b/sh.c
index d321c929b..67d6e4f51 100644
--- a/sh.c
+++ b/sh.c
@@ -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
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)
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