dhcpv6-ia: fix invalid preferred lifetime
authorHans Dedecker <dedeckeh@gmail.com>
Sun, 18 Jul 2021 16:43:26 +0000 (18:43 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Sun, 18 Jul 2021 17:03:25 +0000 (19:03 +0200)
Preferred lifetime cannot be greater than the valid lifetime of an IA;
fix this by checking if the preferred lifetime does not exceed the
valid lifetime of an IA

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

index 639e36878534244e43ba72bc32a1b47748a26209..c378c09607e45811025b9acc221abc580f7422f7 100644 (file)
@@ -896,6 +896,9 @@ static size_t build_ia(uint8_t *buf, size_t buflen, uint16_t status,
                        if (prefix_valid > leasetime)
                                prefix_valid = leasetime;
 
+                       if (prefix_pref > prefix_valid)
+                               prefix_pref = prefix_valid;
+
                        if (a->flags & OAF_DHCPV6_PD) {
                                struct dhcpv6_ia_prefix o_ia_p = {
                                        .type = htons(DHCPV6_OPT_IA_PREFIX),