From 3976533f2cdbf4373a9ea71197aead3e5699aef0 Mon Sep 17 00:00:00 2001 From: Francois-Xavier Le Bail Date: Fri, 14 Sep 2018 17:34:47 +0200 Subject: [PATCH] Remove some useless tests Because packet length (length) >= capture length (caplen). (see the sanity checks in print.c, pretty_print_packet() function) --- print-arcnet.c | 10 +++++----- print-atm.c | 6 +++--- print-bt.c | 2 +- print-nflog.c | 6 +++--- print-pktap.c | 4 ++-- print-ppp.c | 2 +- print-sl.c | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/print-arcnet.c b/print-arcnet.c index b5831c23..adc846ff 100644 --- a/print-arcnet.c +++ b/print-arcnet.c @@ -191,7 +191,7 @@ arcnet_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_ch u_char arc_type; ndo->ndo_protocol = "arcnet_if"; - if (caplen < ARC_HDRLEN || length < ARC_HDRLEN) { + if (caplen < ARC_HDRLEN) { nd_print_trunc(ndo); return (caplen); } @@ -212,7 +212,7 @@ arcnet_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_ch } if (phds) { - if (caplen < ARC_HDRNEWLEN || length < ARC_HDRNEWLEN) { + if (caplen < ARC_HDRNEWLEN) { arcnet_print(ndo, p, length, 0, 0, 0); ND_PRINT("[|phds]"); return (caplen); @@ -220,7 +220,7 @@ arcnet_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_ch flag = EXTRACT_U_1(ap->arc_flag); if (flag == 0xff) { - if (caplen < ARC_HDRNEWLEN_EXC || length < ARC_HDRNEWLEN_EXC) { + if (caplen < ARC_HDRNEWLEN_EXC) { arcnet_print(ndo, p, length, 0, 0, 0); ND_PRINT("[|phds extended]"); return (caplen); @@ -279,7 +279,7 @@ arcnet_linux_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, cons u_char arc_type; ndo->ndo_protocol = "arcnet_linux_if"; - if (caplen < ARC_LINUX_HDRLEN || length < ARC_LINUX_HDRLEN) { + if (caplen < ARC_LINUX_HDRLEN) { nd_print_trunc(ndo); return (caplen); } @@ -290,7 +290,7 @@ arcnet_linux_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, cons switch (arc_type) { default: archdrlen = ARC_LINUX_HDRNEWLEN; - if (caplen < ARC_LINUX_HDRNEWLEN || length < ARC_LINUX_HDRNEWLEN) { + if (caplen < ARC_LINUX_HDRNEWLEN) { nd_print_trunc(ndo); return (caplen); } diff --git a/print-atm.c b/print-atm.c index 06ecc017..3bc135d7 100644 --- a/print-atm.c +++ b/print-atm.c @@ -253,7 +253,7 @@ atm_if_print(netdissect_options *ndo, u_int hdrlen = 0; ndo->ndo_protocol = "atm_if"; - if (caplen < 1 || length < 1) { + if (caplen < 1) { nd_print_trunc(ndo); return (caplen); } @@ -270,7 +270,7 @@ atm_if_print(netdissect_options *ndo, * Must have at least a DSAP, an SSAP, and the first byte of the * control field. */ - if (caplen < 3 || length < 3) { + if (caplen < 3) { nd_print_trunc(ndo); return (caplen); } @@ -302,7 +302,7 @@ atm_if_print(netdissect_options *ndo, * packets? If so, could it be changed to use a * new DLT_IEEE802_6 value if we added it? */ - if (caplen < 20 || length < 20) { + if (caplen < 20) { nd_print_trunc(ndo); return (caplen); } diff --git a/print-bt.c b/print-bt.c index 411642b4..d380770c 100644 --- a/print-bt.c +++ b/print-bt.c @@ -54,7 +54,7 @@ bt_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char * const bluetooth_h4_header* hdr = (const bluetooth_h4_header*)p; ndo->ndo_protocol = "bt_if"; - if (caplen < BT_HDRLEN || length < BT_HDRLEN) + if (caplen < BT_HDRLEN) goto trunc; caplen -= BT_HDRLEN; length -= BT_HDRLEN; diff --git a/print-nflog.c b/print-nflog.c index 849b54d1..28929747 100644 --- a/print-nflog.c +++ b/print-nflog.c @@ -139,7 +139,7 @@ nflog_if_print(netdissect_options *ndo, u_int length = h->len; ndo->ndo_protocol = "nflog_if"; - if (caplen < sizeof(nflog_hdr_t) || length < sizeof(nflog_hdr_t)) + if (caplen < sizeof(nflog_hdr_t)) goto trunc; ND_TCHECK_SIZE(hdr); @@ -159,7 +159,7 @@ nflog_if_print(netdissect_options *ndo, const nflog_tlv_t *tlv; /* We have some data. Do we have enough for the TLV header? */ - if (caplen < sizeof(nflog_tlv_t) || length < sizeof(nflog_tlv_t)) + if (caplen < sizeof(nflog_tlv_t)) goto trunc; /* No. */ tlv = (const nflog_tlv_t *) p; @@ -173,7 +173,7 @@ nflog_if_print(netdissect_options *ndo, goto trunc; /* Yes. Give up now. */ /* Do we have enough data for the full TLV? */ - if (caplen < size || length < size) + if (caplen < size) goto trunc; /* No. */ if (EXTRACT_HE_U_2(tlv->tlv_type) == NFULA_PAYLOAD) { diff --git a/print-pktap.c b/print-pktap.c index 05ab987b..0e10aeba 100644 --- a/print-pktap.c +++ b/print-pktap.c @@ -107,7 +107,7 @@ pktap_if_print(netdissect_options *ndo, struct pcap_pkthdr nhdr; ndo->ndo_protocol = "pktap_if"; - if (caplen < sizeof(pktap_header_t) || length < sizeof(pktap_header_t)) { + if (caplen < sizeof(pktap_header_t)) { nd_print_trunc(ndo); return (caplen); } @@ -125,7 +125,7 @@ pktap_if_print(netdissect_options *ndo, nd_print_trunc(ndo); return (caplen); } - if (caplen < hdrlen || length < hdrlen) { + if (caplen < hdrlen) { nd_print_trunc(ndo); return (caplen); } diff --git a/print-ppp.c b/print-ppp.c index 86581ce0..92fffe42 100644 --- a/print-ppp.c +++ b/print-ppp.c @@ -1695,7 +1695,7 @@ ppp_hdlc_if_print(netdissect_options *ndo, switch (EXTRACT_U_1(p)) { case PPP_ADDRESS: - if (caplen < 4 || length < 4) { + if (caplen < 4) { nd_print_trunc(ndo); return (caplen); } diff --git a/print-sl.c b/print-sl.c index 5bba17ab..38ecb70d 100644 --- a/print-sl.c +++ b/print-sl.c @@ -63,7 +63,7 @@ sl_if_print(netdissect_options *ndo, const struct ip *ip; ndo->ndo_protocol = "sl_if"; - if (caplen < SLIP_HDRLEN || length < SLIP_HDRLEN) { + if (caplen < SLIP_HDRLEN) { nd_print_trunc(ndo); return (caplen); } @@ -76,7 +76,7 @@ sl_if_print(netdissect_options *ndo, if (ndo->ndo_eflag) sliplink_print(ndo, p, ip, length); - if (caplen < 1 || length < 1) { + if (caplen < 1) { nd_print_trunc(ndo); return (caplen + SLIP_HDRLEN); }