summaryrefslogtreecommitdiffstats
path: root/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2014-09-26 21:50:52 +0000
committerRoy Marples <roy@marples.name>2014-09-26 21:50:52 +0000
commit06fd488ca195cc99deeb31bdfdbda59b017706fa (patch)
tree0853a8ed08824f6a866b0ac2406f39503ccc2446 /dhcpcd.c
parent94e34c6e6d06983c527a5c64dc7f2ebcdb2cce32 (diff)
downloaddhcpcd-06fd488ca195cc99deeb31bdfdbda59b017706fa.tar.xz
Fix a memory error when ia_* config exists but IPv6 is disabled.
Diffstat (limited to 'dhcpcd.c')
-rw-r--r--dhcpcd.c34
1 files changed, 15 insertions, 19 deletions
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