X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fodhcpd.git;a=blobdiff_plain;f=src%2Fdhcpv6-ia.c;h=9b8c47927b32b6a7ab733d0392073325a60a8708;hp=a4598df762913cdae46234287dc33bdc2d061a1f;hb=01d3f9d64486ac1daa144848944e877e7f0cb762;hpb=56b4e844baad6ea8eaaa6a4442583fa5ffa41bc7 diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c index a4598df..9b8c479 100644 --- a/src/dhcpv6-ia.c +++ b/src/dhcpv6-ia.c @@ -92,14 +92,15 @@ int setup_dhcpv6_ia_interface(struct interface *iface, bool enable) struct lease *lease; list_for_each_entry(lease, &leases, head) { // Construct entry - struct dhcpv6_assignment *a = calloc(1, sizeof(*a) + lease->duid_len); + size_t duid_len = lease->duid_len ? lease->duid_len : 14; + struct dhcpv6_assignment *a = calloc(1, sizeof(*a) + duid_len); if (!a) { syslog(LOG_ERR, "Calloc failed for static lease assignment on interface %s", iface->ifname); return -1; } - a->clid_len = lease->duid_len; + a->clid_len = duid_len; a->length = 128; if (lease->hostid) { a->assigned = lease->hostid; @@ -108,7 +109,7 @@ int setup_dhcpv6_ia_interface(struct interface *iface, bool enable) a->assigned = ((i4a / 100) << 8) | (((i4a % 100) / 10) << 4) | (i4a % 10); } odhcpd_urandom(a->key, sizeof(a->key)); - memcpy(a->clid_data, lease->duid, a->clid_len); + memcpy(a->clid_data, lease->duid, lease->duid_len); memcpy(a->mac, lease->mac.ether_addr_octet, sizeof(a->mac)); // Assign to all interfaces @@ -739,7 +740,7 @@ static size_t append_reply(uint8_t *buf, size_t buflen, uint16_t status, size_t entrlen = sizeof(n) - 4; if (iface->managed < RELAYD_MANAGED_NO_AFLAG && i != m && - addrs[i].prefix == 64) + addrs[i].prefix <= 64) continue; if (datalen + entrlen + 4 > buflen || a->assigned == 0)