The missing check in lsa_validate_rt2() may lead to OOB read in OSPFv2
Router-LSA validation for malformed Router-LSAs. The OSPFv3 case is in
fact safe, but the patch improves these checks in uniform way.
Reported-By: TristanInSec@gmail.com
while (buf < bufend)
{
+ if (buf + sizeof(struct ospf_lsa_rt2_link) > bufend)
+ return 0;
+
struct ospf_lsa_rt2_link *l = buf;
buf += sizeof(struct ospf_lsa_rt2_link) + l->no_tos * sizeof(struct ospf_lsa_rt2_tos);
i++;
while (buf < bufend)
{
+ if (buf + sizeof(struct ospf_lsa_rt3_link) > bufend)
+ return 0;
+
struct ospf_lsa_rt3_link *l = buf;
buf += sizeof(struct ospf_lsa_rt3_link);
- if (buf > bufend)
- return 0;
-
if (!((l->type == LSART_PTP) ||
(l->type == LSART_NET) ||
(l->type == LSART_VLNK)))