[BusyBox-cvs] svn commit: trunk/busybox/networking

andersen at busybox.net andersen at busybox.net
Wed Apr 27 11:44:12 UTC 2005


Author: andersen
Date: 2005-04-27 05:44:11 -0600 (Wed, 27 Apr 2005)
New Revision: 10188

Log:
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.


Modified:
   trunk/busybox/networking/ifupdown.c


Changeset:
Modified: trunk/busybox/networking/ifupdown.c
===================================================================
--- trunk/busybox/networking/ifupdown.c	2005-04-27 10:51:38 UTC (rev 10187)
+++ trunk/busybox/networking/ifupdown.c	2005-04-27 11:44:11 UTC (rev 10188)
@@ -150,9 +150,7 @@
 
 static char no_act = 0;
 static char verbose = 0;
-#ifndef __USE_GNU
-static char **environ = NULL;
-#endif
+static char **__myenviron = NULL;
 
 #ifdef CONFIG_FEATURE_IFUPDOWN_IP
 
@@ -963,16 +961,16 @@
 	const int n_env_entries = iface->n_options + 5;
 	char **ppch;
 
-	if (environ != NULL) {
-		for (ppch = environ; *ppch; ppch++) {
+	if (__myenviron != NULL) {
+		for (ppch = __myenviron; *ppch; ppch++) {
 			free(*ppch);
 			*ppch = NULL;
 		}
-		free(environ);
-		environ = NULL;
+		free(__myenviron);
+		__myenviron = NULL;
 	}
-	environ = xmalloc(sizeof(char *) * (n_env_entries + 1 /* for final NULL */ ));
-	environend = environ;
+	__myenviron = xmalloc(sizeof(char *) * (n_env_entries + 1 /* for final NULL */ ));
+	environend = __myenviron;
 	*environend = NULL;
 
 	for (i = 0; i < iface->n_options; i++) {
@@ -1012,7 +1010,7 @@
 			case -1:		/* failure */
 				return 0;
 			case 0:		/* child */
-				execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, NULL, environ);
+				execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, NULL, __myenviron);
 				exit(127);
 		}
 		waitpid(child, &status, 0);




More information about the busybox-cvs mailing list