From: Roy Marples Date: Wed, 9 Jun 2010 16:51:40 +0000 (+0000) Subject: Fix crash with last patch for rebinding interfaces X-Git-Tag: v5.2.5~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=378f8fa4ab23003beced0700c6e59855ec37d542;p=thirdparty%2Fdhcpcd.git Fix crash with last patch for rebinding interfaces --- diff --git a/dhcpcd.c b/dhcpcd.c index 0d7d830c..fc659a13 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -1369,8 +1369,10 @@ reconf_reboot(int action, int argc, char **argv, int oi) for (ifn = ifs; ifn; ifn = ifn->next) if (strcmp(ifn->name, ifp->name) == 0) break; - if (ifn == NULL) + if (ifn == NULL) { + ifl = ifp->next; stop_interface(ifp); + } } } @@ -1408,7 +1410,7 @@ handle_signal(_unused void *arg) struct interface *ifp, *ifl; struct if_options *ifo; int sig = signal_read(); - int do_release, do_rebind; + int do_release, do_rebind, i; do_rebind = do_release = 0; switch (sig) { @@ -1420,7 +1422,18 @@ handle_signal(_unused void *arg) break; case SIGALRM: syslog(LOG_INFO, "received SIGALRM, rebinding"); + for (i = 0; i < ifac; i++) + free(ifav[i]); + free(ifav); + ifav = NULL; + ifac = 0; + for (i = 0; i < ifdc; i++) + free(ifdv[i]); + free(ifdv); + ifdc = 0; + ifdv = NULL; ifo = read_config(cffile, NULL, NULL, NULL); + add_options(ifo, margc, margv); /* We need to preserve these two options. */ if (options & DHCPCD_MASTER) ifo->options |= DHCPCD_MASTER; diff --git a/if-options.c b/if-options.c index 43f75ea2..da7f6145 100644 --- a/if-options.c +++ b/if-options.c @@ -524,9 +524,7 @@ parse_option(struct if_options *ifo, int opt, const char *arg) } break; case 'z': - /* We only set this if we haven't got any interfaces */ - if (!ifaces) - ifav = splitv(&ifac, ifav, arg); + ifav = splitv(&ifac, ifav, arg); break; case 'A': ifo->options &= ~DHCPCD_ARP; @@ -712,9 +710,7 @@ parse_option(struct if_options *ifo, int opt, const char *arg) ifo->blacklist[ifo->blacklist_len++] = addr2.s_addr; break; case 'Z': - /* We only set this if we haven't got any interfaces */ - if (!ifaces) - ifdv = splitv(&ifdc, ifdv, arg); + ifdv = splitv(&ifdc, ifdv, arg); break; case O_ARPING: if (parse_addr(&addr, NULL, arg) != 0) @@ -849,8 +845,7 @@ read_config(const char *file, } if (skip) continue; - if (parse_config_line(ifo, option, line) != 1) - break; + parse_config_line(ifo, option, line); } fclose(f);