]> git.proxmox.com Git - mirror_frr.git/commitdiff
ospfd: Fixed some ASAN errors
authorErik Kooistra <me@erikkooistra.nl>
Wed, 28 Apr 2021 13:28:28 +0000 (15:28 +0200)
committerErik Kooistra <me@erikkooistra.nl>
Wed, 28 Apr 2021 13:51:18 +0000 (15:51 +0200)
This fixes 2 asan errors:
If we only have a TLV_ROUTER_ADDR don't continue after we skipped it.
Fixed length when parsing EXT_TLV_LINK_SIZE.

Signed-off-by: Erik Kooistra <me@erikkooistra.nl>
ospfd/ospf_te.c

index f2842538a56a9ac5f378eb0580e8503df09c0e79..1929e3dea40b948fb2cf60c3f72ea7d0be9edac5 100644 (file)
@@ -2153,6 +2153,13 @@ static int ospf_te_parse_te(struct ls_ted *ted, struct ospf_lsa *lsa)
        /* Initialize TLV browsing */
        tlvh = TLV_HDR_TOP(lsa->data);
 
+       uint32_t total_len = TLV_BODY_SIZE(lsa->data) - OSPF_LSA_HEADER_SIZE;
+
+       /* If TE Router-ID is only TLV we are done */
+       if (ntohs(tlvh->type) == TE_TLV_ROUTER_ADDR
+           && total_len == sizeof(struct te_tlv_router_addr))
+               return 0;
+
        /* Skip TE Router-ID if present */
        if (ntohs(tlvh->type) == TE_TLV_ROUTER_ADDR)
                tlvh = TLV_HDR_NEXT(tlvh);
@@ -2756,7 +2763,7 @@ static int ospf_te_parse_ext_link(struct ls_ted *ted, struct ospf_lsa *lsa)
                  &lsa->data->id, &edge->attributes->standard.local);
 
        /* Initialize TLV browsing */
-       len = TLV_BODY_SIZE(&ext->header);
+       len = TLV_BODY_SIZE(&ext->header) - EXT_TLV_LINK_SIZE;
        tlvh = (struct tlv_header *)((char *)(ext) + TLV_HDR_SIZE
                                     + EXT_TLV_LINK_SIZE);
        for (; sum < len; tlvh = TLV_HDR_NEXT(tlvh)) {