Remove some useless tests

Because packet length (length) >= capture length (caplen).

(see the sanity checks in print.c, pretty_print_packet() function)
This commit is contained in:
Francois-Xavier Le Bail 2018-09-14 17:34:47 +02:00
parent 6795da23af
commit 3976533f2c
7 changed files with 17 additions and 17 deletions

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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) {

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}