aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2005-04-27 11:44:11 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2005-04-27 11:44:11 +0000
commit6b306205c09ec69093618426caef2cc93242b737 (patch)
treeb1a41edfd3a1eb50b918bbdd09e41a0d1c13ee4f
parentd32ba7c18542a261f8d27aadd75c36bc79d6ac5e (diff)
downloadbusybox-w32-6b306205c09ec69093618426caef2cc93242b737.tar.gz
busybox-w32-6b306205c09ec69093618426caef2cc93242b737.tar.bz2
busybox-w32-6b306205c09ec69093618426caef2cc93242b737.zip
Do not attempt to free() the application's environment, which is was
not dynamically allocated. Instead, use a private variable to store the environment array, which is used when we exec applications. git-svn-id: svn://busybox.net/trunk/busybox@10188 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--networking/ifupdown.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 916948175..e07167aef 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -150,9 +150,7 @@ struct interfaces_file_t
150 150
151static char no_act = 0; 151static char no_act = 0;
152static char verbose = 0; 152static char verbose = 0;
153#ifndef __USE_GNU 153static char **__myenviron = NULL;
154static char **environ = NULL;
155#endif
156 154
157#ifdef CONFIG_FEATURE_IFUPDOWN_IP 155#ifdef CONFIG_FEATURE_IFUPDOWN_IP
158 156
@@ -963,16 +961,16 @@ static void set_environ(struct interface_defn_t *iface, char *mode)
963 const int n_env_entries = iface->n_options + 5; 961 const int n_env_entries = iface->n_options + 5;
964 char **ppch; 962 char **ppch;
965 963
966 if (environ != NULL) { 964 if (__myenviron != NULL) {
967 for (ppch = environ; *ppch; ppch++) { 965 for (ppch = __myenviron; *ppch; ppch++) {
968 free(*ppch); 966 free(*ppch);
969 *ppch = NULL; 967 *ppch = NULL;
970 } 968 }
971 free(environ); 969 free(__myenviron);
972 environ = NULL; 970 __myenviron = NULL;
973 } 971 }
974 environ = xmalloc(sizeof(char *) * (n_env_entries + 1 /* for final NULL */ )); 972 __myenviron = xmalloc(sizeof(char *) * (n_env_entries + 1 /* for final NULL */ ));
975 environend = environ; 973 environend = __myenviron;
976 *environend = NULL; 974 *environend = NULL;
977 975
978 for (i = 0; i < iface->n_options; i++) { 976 for (i = 0; i < iface->n_options; i++) {
@@ -1012,7 +1010,7 @@ static int doit(char *str)
1012 case -1: /* failure */ 1010 case -1: /* failure */
1013 return 0; 1011 return 0;
1014 case 0: /* child */ 1012 case 0: /* child */
1015 execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, NULL, environ); 1013 execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, NULL, __myenviron);
1016 exit(127); 1014 exit(127);
1017 } 1015 }
1018 waitpid(child, &status, 0); 1016 waitpid(child, &status, 0);