]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Remove some now redundant ND_TCHECK_LEN(e, sizeof(nd_ipv4)) calls
authorFrancois-Xavier Le Bail <[email protected]>
Mon, 7 Sep 2020 09:22:49 +0000 (11:22 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Tue, 8 Sep 2020 12:35:21 +0000 (14:35 +0200)
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
print-isoclns.c
print-ldp.c
print-olsr.c
print-pim.c

index 0e45ee3eda48511cfbbb6074bc052c24cfb6cc8c..4218c4b1af707167f96751cb646914b017b03848 100644 (file)
@@ -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));
index 288c4b183ace5967c2cef7aacf1d9f8863463c3b..e842a008a773387945e5938bd606917a5e882eb5 100644 (file)
@@ -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);
index 282bed62f64b9430a5ad38d84bb931476108626e..7f029e6d8bd534ee949b7f39204b4a42a4da8af4 100644 (file)
@@ -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);
index 93f979cdc3e0df81ca607182e48f417894fdb61c..2b85d67c2c394a1d7f1f1c29ce87ced57e2ebfec 100644 (file)
@@ -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;
 }
 
 
index 186f84b5392b1ee56faa5717edf0a006021aa40a..4c67f1e7d0dffbf730dddd6890f2a15f8efadccc 100644 (file)
@@ -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)