aboutsummaryrefslogtreecommitdiff
path: root/networking/nameif.c
diff options
context:
space:
mode:
authorThomas De Schampheleire <thomas.de.schampheleire@gmail.com>2013-02-28 10:31:54 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-02-28 10:31:54 +0100
commitbc0ffc0e971c61dc7f09aab2a35966f99cc606ba (patch)
treef0a55db00108f5a03f94f443f333f881833e098b /networking/nameif.c
parent1e43a381b20f74ff3ff911daa28c9c9c799bcd82 (diff)
downloadbusybox-w32-bc0ffc0e971c61dc7f09aab2a35966f99cc606ba.tar.gz
busybox-w32-bc0ffc0e971c61dc7f09aab2a35966f99cc606ba.tar.bz2
busybox-w32-bc0ffc0e971c61dc7f09aab2a35966f99cc606ba.zip
nameif: fix use-after-free in ENABLE_FEATURE_CLEAN_UP code
Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/nameif.c')
-rw-r--r--networking/nameif.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/networking/nameif.c b/networking/nameif.c
index 5d7e8f9a4..9a8846dc0 100644
--- a/networking/nameif.c
+++ b/networking/nameif.c
@@ -292,12 +292,11 @@ int nameif_main(int argc UNUSED_PARAM, char **argv)
292 if (ch->mac && memcmp(ch->mac, ifr.ifr_hwaddr.sa_data, ETH_ALEN) != 0) 292 if (ch->mac && memcmp(ch->mac, ifr.ifr_hwaddr.sa_data, ETH_ALEN) != 0)
293 continue; 293 continue;
294 /* if we came here, all selectors have matched */ 294 /* if we came here, all selectors have matched */
295 break; 295 goto found;
296 } 296 }
297 /* Nothing found for current interface */ 297 /* Nothing found for current interface */
298 if (!ch) 298 continue;
299 continue; 299 found:
300
301 if (strcmp(ifr.ifr_name, ch->ifname) != 0) { 300 if (strcmp(ifr.ifr_name, ch->ifname) != 0) {
302 strcpy(ifr.ifr_newname, ch->ifname); 301 strcpy(ifr.ifr_newname, ch->ifname);
303 ioctl_or_perror_and_die(ctl_sk, SIOCSIFNAME, &ifr, 302 ioctl_or_perror_and_die(ctl_sk, SIOCSIFNAME, &ifr,
@@ -313,10 +312,14 @@ int nameif_main(int argc UNUSED_PARAM, char **argv)
313 ch->next->prev = ch->prev; 312 ch->next->prev = ch->prev;
314 if (ENABLE_FEATURE_CLEAN_UP) 313 if (ENABLE_FEATURE_CLEAN_UP)
315 delete_eth_table(ch); 314 delete_eth_table(ch);
316 } 315 } /* while */
316
317 if (ENABLE_FEATURE_CLEAN_UP) { 317 if (ENABLE_FEATURE_CLEAN_UP) {
318 for (ch = clist; ch; ch = ch->next) 318 ethtable_t *next;
319 for (ch = clist; ch; ch = next) {
320 next = ch->next;
319 delete_eth_table(ch); 321 delete_eth_table(ch);
322 }
320 config_close(parser); 323 config_close(parser);
321 }; 324 };
322 325