From: Roy Marples Date: Fri, 26 Sep 2014 21:50:52 +0000 (+0000) Subject: Fix a memory error when ia_* config exists but IPv6 is disabled. X-Git-Tag: v6.4.6~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=06fd488ca195cc99deeb31bdfdbda59b017706fa;p=thirdparty%2Fdhcpcd.git Fix a memory error when ia_* config exists but IPv6 is disabled. --- diff --git a/dhcpcd.c b/dhcpcd.c index 1f122b3f..6d83a149 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -454,27 +454,23 @@ configure_interface1(struct interface *ifp) } #ifdef INET6 - if (ifo->options & DHCPCD_IPV6) { - if (ifo->ia == NULL) { - ifo->ia = malloc(sizeof(*ifo->ia)); - if (ifo->ia == NULL) - syslog(LOG_ERR, "%s: %m", __func__); - else { - ifo->ia_len = 1; - ifo->ia->ia_type = D6_OPTION_IA_NA; + if (ifo->ia == NULL && ifo->options & DHCPCD_IPV6) { + ifo->ia = malloc(sizeof(*ifo->ia)); + if (ifo->ia == NULL) + syslog(LOG_ERR, "%s: %m", __func__); + else { + ifo->ia_len = 1; + ifo->ia->ia_type = D6_OPTION_IA_NA; + memcpy(ifo->ia->iaid, ifo->iaid, sizeof(ifo->iaid)); + memset(&ifo->ia->addr, 0, sizeof(ifo->ia->addr)); + ifo->ia->sla = NULL; + ifo->ia->sla_len = 0; + } + } else { + for (i = 0; i < ifo->ia_len; i++) { + if (!ifo->ia[i].iaid_set) memcpy(ifo->ia->iaid, ifo->iaid, sizeof(ifo->iaid)); - memset(&ifo->ia->addr, 0, - sizeof(ifo->ia->addr)); - ifo->ia->sla = NULL; - ifo->ia->sla_len = 0; - } - } else { - for (i = 0; i < ifo->ia_len; i++) { - if (!ifo->ia[i].iaid_set) - memcpy(ifo->ia->iaid, ifo->iaid, - sizeof(ifo->iaid)); - } } } #endif