diff options
| author | Roy Marples <roy@marples.name> | 2014-09-26 21:50:52 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2014-09-26 21:50:52 +0000 |
| commit | 06fd488ca195cc99deeb31bdfdbda59b017706fa (patch) | |
| tree | 0853a8ed08824f6a866b0ac2406f39503ccc2446 /dhcpcd.c | |
| parent | 94e34c6e6d06983c527a5c64dc7f2ebcdb2cce32 (diff) | |
| download | dhcpcd-06fd488ca195cc99deeb31bdfdbda59b017706fa.tar.xz | |
Fix a memory error when ia_* config exists but IPv6 is disabled.
Diffstat (limited to 'dhcpcd.c')
| -rw-r--r-- | dhcpcd.c | 34 |
1 files changed, 15 insertions, 19 deletions
@@ -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 |
