The LLS data length is in 32-bit words, not bytes. Also, minimal valid
length should be checked. BIRD does not process LLS data field, but it
must be skipped properly when OSPFv3 authentication is verified.
Also, the old code could lead to crash due to unaligned access when
processing OSPFv3 packets with LLS headers.
DROP("packet length mismatch", len);
struct ospf_lls *lls = (void *) ((byte *) pkt + plen);
- plen += ntohs(lls->length);
+
+ /* RFC 5613 2.2 - LLS data length is in 32-bit words! */
+ uint lls_length = ntohs(lls->length) * 4;
+ if (lls_length < sizeof(struct ospf_lls))
+ DROP("LLS data too short", lls_length);
+
+ if ((plen + lls_length) > len)
+ DROP("packet length mismatch", len);
+
+ plen += lls_length;
}
if ((plen + sizeof(struct ospf_auth3)) > len)