]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
dhcp6: fix a memory issue with prior patch
authorRoy Marples <roy@marples.name>
Tue, 8 May 2018 11:39:26 +0000 (12:39 +0100)
committerRoy Marples <roy@marples.name>
Tue, 8 May 2018 11:39:26 +0000 (12:39 +0100)
Don't allocate memory for T1 or T2 timers when requesting
IA_TA addresses.

src/dhcp6.c

index a557632ea082dad5c0078b5ac141f672eee01833..6eb3f4485e2beea2e8cdcb9941b0983aa68183c9 100644 (file)
@@ -778,7 +778,13 @@ dhcp6_makemessage(struct interface *ifp)
                }
                /* FALLTHROUGH */
        case DH6S_INIT:
-               len += ifo->ia_len * (sizeof(o) + (sizeof(uint32_t) * 3));
+               for (l = 0; l < ifo->ia_len; l++) {
+                       ifia = &ifo->ia[l];
+                       len += sizeof(o) + sizeof(uint32_t); /* IAID */
+                       /* IA_TA does not have T1 or T2 timers */
+                       if (ifo->ia[l].ia_type != D6_OPTION_IA_TA)
+                               len += sizeof(uint32_t) + sizeof(uint32_t);
+               }
                IA = 1;
                break;
        default: