dhcpv6-ia: fix onlink IA check (FS#2060)
[project/odhcpd.git] / src / dhcpv6-ia.c
index fb1c22860fe571e4c8e00f3c7d3810799d4af51e..de7e673e18f569c0d6d3dca2db824324874cd102 100644 (file)
@@ -1102,7 +1102,7 @@ static bool dhcpv6_ia_on_link(const struct dhcpv6_ia_hdr *ia, struct dhcpv6_assi
        time_t now = odhcpd_time();
        uint8_t *odata, *end = ((uint8_t*)ia) + htons(ia->len) + 4;
        uint16_t otype, olen;
-       bool onlink = false;
+       bool onlink = true;
 
        dhcpv6_for_each_option((uint8_t*)&ia[1], end, otype, olen, odata) {
                struct dhcpv6_ia_prefix *p = (struct dhcpv6_ia_prefix*)&odata[-4];
@@ -1112,7 +1112,7 @@ static bool dhcpv6_ia_on_link(const struct dhcpv6_ia_hdr *ia, struct dhcpv6_assi
                                (otype != DHCPV6_OPT_IA_ADDR || olen < sizeof(*n) - 4))
                        continue;
 
-               for (size_t i = 0; i < addrlen; ++i) {
+               for (size_t i = 0, onlink = false; i < addrlen; ++i) {
                        struct in6_addr addr = addrs[i].addr.in6;
 
                        if (!valid_addr(&addrs[i], now))