dhcpv6-ia: fix logic to include IA_PD prefix with lifetimes set to 0
authorHans Dedecker <dedeckeh@gmail.com>
Thu, 24 Dec 2020 15:08:58 +0000 (16:08 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Thu, 24 Dec 2020 15:25:59 +0000 (16:25 +0100)
Make sure IA_PD prefixes for which no preferred and valid lifetimes
can be returned are included in the reply with a preferred and valid
lifetime to 0.
Therefore exclude IPv6 prefixes with an invalid prefix length as
well so IA_PD prefixes for which not a preferred/valid lifetime is
returned are included with a preferred and valid lifetime set to 0

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
src/dhcpv6-ia.c

index 2de971070df10008965a190d693fae223a133eb8..42268e5b879a97e6732d9d7cbdf556cec0f54c75 100644 (file)
@@ -949,7 +949,8 @@ static size_t build_ia(uint8_t *buf, size_t buflen, uint16_t status,
                                size_t addrlen = (a->managed) ? (size_t)a->managed_size : iface->addr6_len;
 
                                for (size_t i = 0; i < addrlen; ++i) {
-                                       if (!valid_addr(&addrs[i], now))
+                                       if (!valid_addr(&addrs[i], now) ||
+                                           !valid_prefix_length(a, addrs[i].prefix))
                                                continue;
 
                                        struct in6_addr addr = addrs[i].addr.in6;