From 3b8ff4bf0d8f389e00c19d6c094bce2bbf00deca Mon Sep 17 00:00:00 2001 From: Francois-Xavier Le Bail Date: Mon, 7 Sep 2020 11:22:49 +0200 Subject: Remove some now redundant ND_TCHECK_LEN(e, sizeof(nd_ipv4)) calls They are redundant because they are followed by a GET_IPADDR_STRING(e) call, same e, which do the bounds check. Remove unused 'trunc' label(s) and associated code(s). --- print-bgp.c | 7 ------- print-isoclns.c | 4 ---- print-ldp.c | 1 - print-olsr.c | 5 ----- print-pim.c | 5 ----- 5 files changed, 22 deletions(-) diff --git a/print-bgp.c b/print-bgp.c index 0e45ee3e..4218c4b1 100644 --- a/print-bgp.c +++ b/print-bgp.c @@ -684,7 +684,6 @@ bgp_vpn_ip_print(netdissect_options *ndo, switch(addr_length) { case (sizeof(nd_ipv4) << 3): /* 32 */ - ND_TCHECK_LEN(pptr, sizeof(nd_ipv4)); snprintf(pos, sizeof(addr), "%s", GET_IPADDR_STRING(pptr)); break; case (sizeof(nd_ipv6) << 3): /* 128 */ @@ -696,7 +695,6 @@ bgp_vpn_ip_print(netdissect_options *ndo, } pos += strlen(pos); -trunc: *(pos) = '\0'; return (addr); } @@ -1116,13 +1114,10 @@ decode_mdt_vpn_nlri(netdissect_options *ndo, pptr += 8; /* IPv4 address */ - ND_TCHECK_LEN(pptr, sizeof(nd_ipv4)); vpn_ip = pptr; pptr += sizeof(nd_ipv4); /* MDT Group Address */ - ND_TCHECK_LEN(pptr, sizeof(nd_ipv4)); - snprintf(buf, buflen, "RD: %s, VPN IP Address: %s, MC Group Address: %s", bgp_vpn_rd_print(ndo, rd), GET_IPADDR_STRING(vpn_ip), GET_IPADDR_STRING(pptr)); @@ -2123,7 +2118,6 @@ bgp_attr_print(netdissect_options *ndo, tlen -= tnhlen; tnhlen = 0; } else { - ND_TCHECK_LEN(tptr, sizeof(nd_ipv4)); ND_PRINT("%s",GET_IPADDR_STRING(tptr)); tptr += sizeof(nd_ipv4); tnhlen -= sizeof(nd_ipv4); @@ -2192,7 +2186,6 @@ bgp_attr_print(netdissect_options *ndo, tlen -= tnhlen; tnhlen = 0; } else { - ND_TCHECK_LEN(tptr, sizeof(nd_ipv4)); ND_PRINT("%s", GET_IPADDR_STRING(tptr)); tptr += (sizeof(nd_ipv4)); tlen -= (sizeof(nd_ipv4)); diff --git a/print-isoclns.c b/print-isoclns.c index 288c4b18..e842a008 100644 --- a/print-isoclns.c +++ b/print-isoclns.c @@ -3236,7 +3236,6 @@ isis_print(netdissect_options *ndo, case ISIS_TLV_TE_ROUTER_ID: if (tlen < sizeof(nd_ipv4)) goto tlv_trunc; - ND_TCHECK_LEN(pptr, sizeof(nd_ipv4)); ND_PRINT("\n\t Traffic Engineering Router ID: %s", GET_IPADDR_STRING(pptr)); break; @@ -3244,7 +3243,6 @@ isis_print(netdissect_options *ndo, while (tlen != 0) { if (tlen < sizeof(nd_ipv4)) goto tlv_trunc; - ND_TCHECK_LEN(tptr, sizeof(nd_ipv4)); ND_PRINT("\n\t IPv4 interface address: %s", GET_IPADDR_STRING(tptr)); tptr += sizeof(nd_ipv4); tlen -= sizeof(nd_ipv4); @@ -3274,14 +3272,12 @@ isis_print(netdissect_options *ndo, if (tlen < sizeof(nd_ipv4)) break; - ND_TCHECK_LEN(tptr, sizeof(nd_ipv4)); ND_PRINT("\n\t IPv4 interface address: %s", GET_IPADDR_STRING(tptr)); tptr+=sizeof(nd_ipv4); tlen-=sizeof(nd_ipv4); if (tlen < sizeof(nd_ipv4)) break; - ND_TCHECK_LEN(tptr, sizeof(nd_ipv4)); ND_PRINT("\n\t IPv4 neighbor address: %s", GET_IPADDR_STRING(tptr)); tptr+=sizeof(nd_ipv4); tlen-=sizeof(nd_ipv4); diff --git a/print-ldp.c b/print-ldp.c index 282bed62..7f029e6d 100644 --- a/print-ldp.c +++ b/print-ldp.c @@ -309,7 +309,6 @@ ldp_tlv_print(netdissect_options *ndo, switch (af) { case AFNUM_INET: while(tlv_tlen >= sizeof(nd_ipv4)) { - ND_TCHECK_LEN(tptr, sizeof(nd_ipv4)); ND_PRINT(" %s", GET_IPADDR_STRING(tptr)); tlv_tlen-=sizeof(nd_ipv4); tptr+=sizeof(nd_ipv4); diff --git a/print-olsr.c b/print-olsr.c index 93f979cd..2b85d67c 100644 --- a/print-olsr.c +++ b/print-olsr.c @@ -294,10 +294,7 @@ olsr_print_neighbor(netdissect_options *ndo, neighbor = 1; while (hello_len >= sizeof(nd_ipv4)) { - - ND_TCHECK_LEN(msg_data, sizeof(nd_ipv4)); /* print 4 neighbors per line */ - ND_PRINT("%s%s", GET_IPADDR_STRING(msg_data), neighbor % 4 == 0 ? "\n\t\t" : " "); @@ -305,8 +302,6 @@ olsr_print_neighbor(netdissect_options *ndo, hello_len -= sizeof(nd_ipv4); } return (0); -trunc: - return -1; } diff --git a/print-pim.c b/print-pim.c index 186f84b5..4c67f1e7 100644 --- a/print-pim.c +++ b/print-pim.c @@ -189,7 +189,6 @@ pimv1_join_prune_print(netdissect_options *ndo, if (len < sizeof(nd_ipv4)) goto trunc; - ND_TCHECK_LEN(bp, sizeof(nd_ipv4)); if (ndo->ndo_vflag > 1) ND_PRINT("\n"); ND_PRINT(" Upstream Nbr: %s", GET_IPADDR_STRING(bp)); @@ -218,13 +217,11 @@ pimv1_join_prune_print(netdissect_options *ndo, */ if (len < 4) goto trunc; - ND_TCHECK_LEN(bp, sizeof(nd_ipv4)); ND_PRINT("\n\tGroup: %s", GET_IPADDR_STRING(bp)); bp += 4; len -= 4; if (len < 4) goto trunc; - ND_TCHECK_LEN(bp, sizeof(nd_ipv4)); if (GET_BE_U_4(bp) != 0xffffffff) ND_PRINT("/%s", GET_IPADDR_STRING(bp)); bp += 4; @@ -303,7 +300,6 @@ pimv1_print(netdissect_options *ndo, GET_IPADDR_STRING(bp + 24)); break; case PIMV1_TYPE_REGISTER_STOP: - ND_TCHECK_LEN(bp + 12, sizeof(nd_ipv4)); ND_PRINT(" for %s > %s", GET_IPADDR_STRING(bp + 8), GET_IPADDR_STRING(bp + 12)); break; @@ -318,7 +314,6 @@ pimv1_print(netdissect_options *ndo, } break; case PIMV1_TYPE_ASSERT: - ND_TCHECK_LEN(bp + 16, sizeof(nd_ipv4)); ND_PRINT(" for %s > %s", GET_IPADDR_STRING(bp + 16), GET_IPADDR_STRING(bp + 8)); if (GET_BE_U_4(bp + 12) != 0xffffffff) -- cgit v1.2.1