]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Remove 15 now redundant ND_TCHECK_n() calls
authorFrancois-Xavier Le Bail <[email protected]>
Thu, 10 Sep 2020 11:24:28 +0000 (13:24 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Thu, 10 Sep 2020 12:06:40 +0000 (14:06 +0200)
ND_TCHECK_n(e).

They are redundant because they are followed by a GET_.*_n(e) call,
same n, same e, which do the bounds check.

Remove unused 'trunc' label(s) and most associated code(s).

print-bgp.c
print-eap.c
print-icmp.c
print-juniper.c
print-nfs.c
print-openflow-1.0.c
print-pim.c
print-snmp.c
print-tipc.c

index ab3e2835539c4bde00573ee4cf293b6034747c41..f4d174915430460da9cfe8bb08b9cad245beef8a 100644 (file)
@@ -1326,7 +1326,6 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
                         }
                         return plen + 2;
                     }
-                    ND_TCHECK_1(pptr);
                     if (buflen != 0) {
                         stringlen=snprintf(buf,buflen, "%02x",
                                               GET_U_1(pptr));
index 2ef9de5e0995a8016aad0370e335b92369210743..82d6084ad092c0ae5488961b3f43c9c23ca35700 100644 (file)
@@ -207,7 +207,6 @@ eap_print(netdissect_options *ndo,
 
             case EAP_TYPE_TTLS:
             case EAP_TYPE_TLS:
-                ND_TCHECK_1(cp + 5);
                 if (subtype == EAP_TYPE_TTLS)
                     ND_PRINT(" TTLSv%u",
                            EAP_TTLS_VERSION(GET_U_1((cp + 5))));
index 59b56c6ab28fbad5de36d2a7ab0ed4416b01a99f..dd767ebab094d9d7112a70609efb4e38fe17773b 100644 (file)
@@ -324,7 +324,6 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
 
        case ICMP_ECHO:
        case ICMP_ECHOREPLY:
-               ND_TCHECK_2(dp->icmp_seq);
                (void)snprintf(buf, sizeof(buf), "echo %s, id %u, seq %u",
                                icmp_type == ICMP_ECHO ?
                                "request" : "reply",
@@ -348,7 +347,6 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
                        break;
 
                case ICMP_UNREACH_PROTOCOL:
-                       ND_TCHECK_1(dp->icmp_ip.ip_p);
                        (void)snprintf(buf, sizeof(buf),
                            "%s protocol %u unreachable",
                            GET_IPADDR_STRING(dp->icmp_ip.ip_dst),
@@ -595,7 +593,6 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
                        (void)snprintf(buf, sizeof(buf),
                            "parameter problem - code %u", icmp_code);
                else {
-                       ND_TCHECK_1(dp->icmp_pptr);
                        (void)snprintf(buf, sizeof(buf),
                            "parameter problem - octet %u",
                            GET_U_1(dp->icmp_pptr));
@@ -608,7 +605,6 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
                break;
 
        case ICMP_TSTAMP:
-               ND_TCHECK_2(dp->icmp_seq);
                (void)snprintf(buf, sizeof(buf),
                    "time stamp query id %u seq %u",
                    GET_BE_U_2(dp->icmp_id),
index 1560cee554dc7db0cc012b5075364779eb87f7c2..164973c6337247bd51acc85efb5f0a8d7e37da00 100644 (file)
@@ -1534,7 +1534,6 @@ juniper_parse_header(netdissect_options *ndo,
 #endif
 #ifdef DLT_JUNIPER_ATM2
     case DLT_JUNIPER_ATM2:
-        ND_TCHECK_4(p);
         /* ATM cell relay control word present ? */
         if (l2info->cookie[7] & ATM2_PKT_TYPE_MASK) {
             control_word = GET_BE_U_4(p);
index a83f1b541885efaa7f98ce1be92947e72e16b80f..20b0cfcef4d8260537b2a3aa690c7cd88b9dab87 100644 (file)
@@ -340,7 +340,6 @@ nfsreply_print(netdissect_options *ndo,
        ndo->ndo_protocol = "nfs";
        rp = (const struct sunrpc_msg *)bp;
 
-       ND_TCHECK_4(rp->rm_xid);
        if (!ndo->ndo_nflag) {
                strlcpy(srcid, "nfs", sizeof(srcid));
                snprintf(dstid, sizeof(dstid), "%u",
@@ -353,10 +352,6 @@ nfsreply_print(netdissect_options *ndo,
        print_nfsaddr(ndo, bp2, srcid, dstid);
 
        nfsreply_noaddr_print(ndo, bp, length, bp2);
-       return;
-
-trunc:
-       nd_print_trunc(ndo);
 }
 
 void
@@ -1317,15 +1312,12 @@ parserddires(netdissect_options *ndo,
        if (ndo->ndo_qflag)
                return (1);
 
-       ND_TCHECK_4(dp + 2);
        ND_PRINT(" offset 0x%x size %u ",
               GET_BE_U_4(dp), GET_BE_U_4(dp + 1));
        if (GET_BE_U_4(dp + 2) != 0)
                ND_PRINT(" eof");
 
        return (1);
-trunc:
-       return (0);
 }
 
 static const uint32_t *
index 6c224b73aaf60eb3670672a6be1dbd4a0d314219..7fb0f4056c5d08ed19f01aa17439657e51bc0fdd 100644 (file)
@@ -1387,7 +1387,6 @@ of10_match_print(netdissect_options *ndo,
                ND_PRINT("%smatch nw_dst %s/%u", pfx, GET_IPADDR_STRING(cp), 32 - nw_bits);
        cp += 4;
        /* tp_src */
-       ND_TCHECK_2(cp);
        if (! (wildcards & OFPFW_TP_SRC)) {
                field_name = ! (wildcards & OFPFW_DL_TYPE) && dl_type == ETHERTYPE_IP
                  && ! (wildcards & OFPFW_NW_PROTO) && nw_proto == IPPROTO_ICMP
@@ -1396,7 +1395,6 @@ of10_match_print(netdissect_options *ndo,
        }
        cp += 2;
        /* tp_dst */
-       ND_TCHECK_2(cp);
        if (! (wildcards & OFPFW_TP_DST)) {
                field_name = ! (wildcards & OFPFW_DL_TYPE) && dl_type == ETHERTYPE_IP
                  && ! (wildcards & OFPFW_NW_PROTO) && nw_proto == IPPROTO_ICMP
index 1fd11472cba34933e4a289cf0f15d2e8dfc19fb7..761ab6e1fc3c03b59d5f6f0f669456beaa4b86b5 100644 (file)
@@ -305,7 +305,6 @@ pimv1_print(netdissect_options *ndo,
                break;
        case PIMV1_TYPE_RP_REACHABILITY:
                if (ndo->ndo_vflag) {
-                       ND_TCHECK_2(bp + 22);
                        ND_PRINT(" group %s", GET_IPADDR_STRING(bp + 8));
                        if (GET_BE_U_4(bp + 12) != 0xffffffff)
                                ND_PRINT("/%s", GET_IPADDR_STRING(bp + 12));
@@ -1091,7 +1090,6 @@ pimv2_print(netdissect_options *ndo,
 
                                if (len < 2)
                                        goto trunc;
-                               ND_TCHECK_2(bp);
                                ND_PRINT(",holdtime=");
                                unsigned_relts_print(ndo,
                                                     GET_BE_U_2(bp));
index 24acaf7f4c1d0f71e162793c6f010544eee18f5c..439dc780fd96b99f4306f901df4344c2900f426e 100644 (file)
@@ -473,7 +473,6 @@ asn1_parse(netdissect_options *ndo,
                        len--;
                        hdr++;
                        p++;
-                       ND_TCHECK_1(p);
                }
                if (len < 1) {
                        ND_PRINT("[Xtagfield?]");
index 3a9897efd826bf9f1ee536271b0ae4135508e0d4..6bb150e0d83fa590332dc5d90d592a1f727b1722 100644 (file)
@@ -317,7 +317,6 @@ print_link_conf(netdissect_options *ndo, const struct link_conf_tipc_pkthdr *ap)
            tok2str(tipcuser_values, "unknown", user),
            tok2str(tipc_linkconf_mtype_values, "Unknown", mtype));
        if (ndo->ndo_vflag) {
-               ND_TCHECK_4(ap->w5);
                node_sig = TIPC_NODE_SIG(w1);
                ntwrk_id = GET_BE_U_4(ap->ntwrk_id);
                w5 = GET_BE_U_4(ap->w5);