diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-19 23:01:33 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-12-19 23:01:33 +0000 |
commit | 8cd1a288fa15c8db5701ad94592c5a6a4562b1a9 (patch) | |
tree | 3e3dfc77159d7818a8d9c40eb15c9a3256974b9c | |
parent | 28703015ab71784f40bc97f720ed900e26bd03ca (diff) | |
download | busybox-w32-8cd1a288fa15c8db5701ad94592c5a6a4562b1a9.tar.gz busybox-w32-8cd1a288fa15c8db5701ad94592c5a6a4562b1a9.tar.bz2 busybox-w32-8cd1a288fa15c8db5701ad94592c5a6a4562b1a9.zip |
ifupdown: parse() returning NULL and returning "" is not the same,
it turned out! wow... okay, fixing my buglet...
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | networking/ifupdown.c | 25 |
2 files changed, 16 insertions, 12 deletions
@@ -573,7 +573,8 @@ ifdef CONFIG_STATIC | |||
573 | -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \ | 573 | -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \ |
574 | -Wl,--start-group $(busybox-all) -Wl,--end-group | 574 | -Wl,--start-group $(busybox-all) -Wl,--end-group |
575 | else | 575 | else |
576 | cmd_busybox__ ?= $(srctree)/scripts/trylink $(CC) -o $@ $(LDFLAGS) \ | 576 | cmd_busybox__ ?= $(srctree)/scripts/trylink $(CC) $(LDFLAGS) \ |
577 | -o $@ \ | ||
577 | -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \ | 578 | -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \ |
578 | -Wl,--start-group $(busybox-all) -Wl,--end-group | 579 | -Wl,--start-group $(busybox-all) -Wl,--end-group |
579 | endif | 580 | endif |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 93d7bc520..90c05444b 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -103,7 +103,7 @@ enum { | |||
103 | #define FORCE (option_mask32 & OPT_force) | 103 | #define FORCE (option_mask32 & OPT_force) |
104 | #define NO_MAPPINGS (option_mask32 & OPT_no_mappings) | 104 | #define NO_MAPPINGS (option_mask32 & OPT_no_mappings) |
105 | 105 | ||
106 | static char **__myenviron; | 106 | static char **my_environ; |
107 | 107 | ||
108 | static char *startup_PATH; | 108 | static char *startup_PATH; |
109 | 109 | ||
@@ -187,7 +187,7 @@ static char *parse(const char *command, struct interface_defn_t *ifd) | |||
187 | size_t old_pos[MAX_OPT_DEPTH] = { 0 }; | 187 | size_t old_pos[MAX_OPT_DEPTH] = { 0 }; |
188 | int okay[MAX_OPT_DEPTH] = { 1 }; | 188 | int okay[MAX_OPT_DEPTH] = { 1 }; |
189 | int opt_depth = 1; | 189 | int opt_depth = 1; |
190 | char *result = xstrdup(""); | 190 | char *result = NULL; |
191 | 191 | ||
192 | while (*command) { | 192 | while (*command) { |
193 | switch (*command) { | 193 | switch (*command) { |
@@ -206,7 +206,7 @@ static char *parse(const char *command, struct interface_defn_t *ifd) | |||
206 | break; | 206 | break; |
207 | case '[': | 207 | case '[': |
208 | if (command[1] == '[' && opt_depth < MAX_OPT_DEPTH) { | 208 | if (command[1] == '[' && opt_depth < MAX_OPT_DEPTH) { |
209 | old_pos[opt_depth] = strlen(result); | 209 | old_pos[opt_depth] = result ? strlen(result) : 0; |
210 | okay[opt_depth] = 1; | 210 | okay[opt_depth] = 1; |
211 | opt_depth++; | 211 | opt_depth++; |
212 | command += 2; | 212 | command += 2; |
@@ -290,7 +290,7 @@ static int execute(const char *command, struct interface_defn_t *ifd, execfn *ex | |||
290 | int ret; | 290 | int ret; |
291 | 291 | ||
292 | out = parse(command, ifd); | 292 | out = parse(command, ifd); |
293 | if (!out || !out[0]) { | 293 | if (!out) { |
294 | return 0; | 294 | return 0; |
295 | } | 295 | } |
296 | ret = (*exec)(out); | 296 | ret = (*exec)(out); |
@@ -871,15 +871,15 @@ static void set_environ(struct interface_defn_t *iface, const char *mode) | |||
871 | const int n_env_entries = iface->n_options + 5; | 871 | const int n_env_entries = iface->n_options + 5; |
872 | char **ppch; | 872 | char **ppch; |
873 | 873 | ||
874 | if (__myenviron != NULL) { | 874 | if (my_environ != NULL) { |
875 | for (ppch = __myenviron; *ppch; ppch++) { | 875 | for (ppch = my_environ; *ppch; ppch++) { |
876 | free(*ppch); | 876 | free(*ppch); |
877 | *ppch = NULL; | 877 | *ppch = NULL; |
878 | } | 878 | } |
879 | free(__myenviron); | 879 | free(my_environ); |
880 | } | 880 | } |
881 | __myenviron = xzalloc(sizeof(char *) * (n_env_entries + 1 /* for final NULL */ )); | 881 | my_environ = xzalloc(sizeof(char *) * (n_env_entries + 1 /* for final NULL */ )); |
882 | environend = __myenviron; | 882 | environend = my_environ; |
883 | 883 | ||
884 | for (i = 0; i < iface->n_options; i++) { | 884 | for (i = 0; i < iface->n_options; i++) { |
885 | if (strcmp(iface->option[i].name, "up") == 0 | 885 | if (strcmp(iface->option[i].name, "up") == 0 |
@@ -903,6 +903,9 @@ static int doit(char *str) | |||
903 | if (option_mask32 & (OPT_no_act|OPT_verbose)) { | 903 | if (option_mask32 & (OPT_no_act|OPT_verbose)) { |
904 | puts(str); | 904 | puts(str); |
905 | } | 905 | } |
906 | /* FIXME: is it true that we can reach this place with str = ""? */ | ||
907 | /* how? in execute() parse() may return "", then we do (*exec)(""); */ | ||
908 | /* Please add a comment... */ | ||
906 | if (!(option_mask32 & OPT_no_act)) { | 909 | if (!(option_mask32 & OPT_no_act)) { |
907 | pid_t child; | 910 | pid_t child; |
908 | int status; | 911 | int status; |
@@ -912,7 +915,7 @@ static int doit(char *str) | |||
912 | case -1: /* failure */ | 915 | case -1: /* failure */ |
913 | return 0; | 916 | return 0; |
914 | case 0: /* child */ | 917 | case 0: /* child */ |
915 | execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, NULL, __myenviron); | 918 | execle(DEFAULT_SHELL, DEFAULT_SHELL, "-c", str, NULL, my_environ); |
916 | exit(127); | 919 | exit(127); |
917 | } | 920 | } |
918 | waitpid(child, &status, 0); | 921 | waitpid(child, &status, 0); |
@@ -1206,7 +1209,7 @@ int ifupdown_main(int argc, char **argv) | |||
1206 | okay = 1; | 1209 | okay = 1; |
1207 | currif->iface = iface; | 1210 | currif->iface = iface; |
1208 | 1211 | ||
1209 | debug_noise("\nZ Configuring interface %s (%s)\n", liface, currif->address_family->name); | 1212 | debug_noise("\nConfiguring interface %s (%s)\n", liface, currif->address_family->name); |
1210 | 1213 | ||
1211 | /* Call the cmds function pointer, does either iface_up() or iface_down() */ | 1214 | /* Call the cmds function pointer, does either iface_up() or iface_down() */ |
1212 | cmds_ret = cmds(currif); | 1215 | cmds_ret = cmds(currif); |