summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--netdissect.h40
-rw-r--r--print-aodv.c19
-rw-r--r--print-atalk.c14
-rw-r--r--print-egp.c2
-rw-r--r--print-ether.c2
-rw-r--r--print-geneve.c4
-rw-r--r--print-gre.c32
-rw-r--r--print-ipx.c4
-rw-r--r--print-juniper.c3
-rw-r--r--print-l2tp.c2
-rw-r--r--print-olsr.c14
-rw-r--r--print-ptp.c2
-rw-r--r--print-rip.c18
-rw-r--r--print-rsvp.c6
-rw-r--r--print-sflow.c2
-rw-r--r--print-udp.c5
-rw-r--r--print-zep.c6
17 files changed, 98 insertions, 77 deletions
diff --git a/netdissect.h b/netdissect.h
index 6bc442fc..5b104df6 100644
--- a/netdissect.h
+++ b/netdissect.h
@@ -384,27 +384,39 @@ extern void nd_pop_all_packet_info(netdissect_options *);
*/
#define ND_BYTES_AVAILABLE_AFTER(p) ND_BYTES_BETWEEN(ndo->ndo_snapend, (p))
-/* Check length < minimum for invalid packet with a custom message, format %u */
-#define ND_LCHECKMSG_U(length, minimum, what) \
-if ((length) < (minimum)) { \
-ND_PRINT(" [%s %u < %u]", (what), (length), (minimum)); \
+/*
+ * Check (expression_1 operator expression_2) for invalid packet with
+ * a custom message, format %u
+ */
+#define ND_ICHECKMSG_U(message, expression_1, operator, expression_2) \
+if ((expression_1) operator (expression_2)) { \
+ND_PRINT(" [%s %u %s %u]", (message), (expression_1), (#operator), (expression_2)); \
goto invalid; \
}
-/* Check length < minimum for invalid packet with #length message, format %u */
-#define ND_LCHECK_U(length, minimum) \
-ND_LCHECKMSG_U((length), (minimum), (#length))
+/*
+ * Check (expression_1 operator expression_2) for invalid packet with
+ * "expression_1" message, format %u
+ */
+#define ND_ICHECK_U(expression_1, operator, expression_2) \
+ND_ICHECKMSG_U((#expression_1), (expression_1), operator, (expression_2))
-/* Check length < minimum for invalid packet with a custom message, format %zu */
-#define ND_LCHECKMSG_ZU(length, minimum, what) \
-if ((length) < (minimum)) { \
-ND_PRINT(" [%s %u < %zu]", (what), (length), (minimum)); \
+/*
+ * Check (expression_1 operator expression_2) for invalid packet with
+ * a custom message, format %zu
+ */
+#define ND_ICHECKMSG_ZU(message, expression_1, operator, expression_2) \
+if ((expression_1) operator (expression_2)) { \
+ND_PRINT(" [%s %u %s %zu]", (message), (expression_1), (#operator), (expression_2)); \
goto invalid; \
}
-/* Check length < minimum for invalid packet with #length message, format %zu */
-#define ND_LCHECK_ZU(length, minimum) \
-ND_LCHECKMSG_ZU((length), (minimum), (#length))
+/*
+ * Check (expression_1 operator expression_2) for invalid packet with
+ * "expression_1" message, format %zu
+ */
+#define ND_ICHECK_ZU(expression_1, operator, expression_2) \
+ND_ICHECKMSG_ZU((#expression_1), (expression_1), operator, (expression_2))
#define ND_PRINT(...) (ndo->ndo_printf)(ndo, __VA_ARGS__)
#define ND_DEFAULTPRINT(ap, length) (*ndo->ndo_default_print)(ndo, ap, length)
diff --git a/print-aodv.c b/print-aodv.c
index da3c37c9..b014c49c 100644
--- a/print-aodv.c
+++ b/print-aodv.c
@@ -161,7 +161,8 @@ aodv_extension(netdissect_options *ndo,
switch (ext_type) {
case AODV_EXT_HELLO:
ah = (const struct aodv_hello *)(const void *)ep;
- ND_LCHECKMSG_ZU(length, sizeof(struct aodv_hello), "ext data length");
+ ND_ICHECKMSG_ZU("ext data length", length, <,
+ sizeof(struct aodv_hello));
if (ext_length < 4) {
ND_PRINT("\n\text HELLO - bad length %u", ext_length);
goto invalid;
@@ -186,7 +187,7 @@ aodv_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
u_int i;
const struct aodv_rreq *ap = (const struct aodv_rreq *)dat;
- ND_LCHECKMSG_ZU(length, sizeof(*ap), "message length");
+ ND_ICHECKMSG_ZU("message length", length, <, sizeof(*ap));
ND_PRINT(" %u %s%s%s%s%shops %u id 0x%08x\n"
"\tdst %s seq %u src %s seq %u", length,
GET_U_1(ap->rreq_type) & RREQ_JOIN ? "[J]" : "",
@@ -215,7 +216,7 @@ aodv_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
u_int i;
const struct aodv_rrep *ap = (const struct aodv_rrep *)dat;
- ND_LCHECKMSG_ZU(length, sizeof(*ap), "message length");
+ ND_ICHECKMSG_ZU("message length", length, <, sizeof(*ap));
ND_PRINT(" %u %s%sprefix %u hops %u\n"
"\tdst %s dseq %u src %s %u ms", length,
GET_U_1(ap->rrep_type) & RREP_REPAIR ? "[R]" : "",
@@ -242,14 +243,14 @@ aodv_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
const struct rerr_unreach *dp;
- ND_LCHECKMSG_ZU(length, sizeof(*ap), "message length");
+ ND_ICHECKMSG_ZU("message length", length, <, sizeof(*ap));
ND_PRINT(" %s [items %u] [%u]:",
GET_U_1(ap->rerr_flags) & RERR_NODELETE ? "[D]" : "",
GET_U_1(ap->rerr_dc), length);
dp = (const struct rerr_unreach *)(dat + sizeof(*ap));
i = length - sizeof(*ap);
for (dc = GET_U_1(ap->rerr_dc); dc != 0; dc--) {
- ND_LCHECKMSG_ZU(i, sizeof(*dp), "remaining length");
+ ND_ICHECKMSG_ZU("remaining length", i, <, sizeof(*dp));
ND_PRINT(" {%s}(%u)", GET_IPADDR_STRING(dp->u_da),
GET_BE_U_4(dp->u_ds));
dp++;
@@ -267,7 +268,7 @@ aodv_v6_rreq(netdissect_options *ndo, const u_char *dat, u_int length)
u_int i;
const struct aodv_rreq6 *ap = (const struct aodv_rreq6 *)dat;
- ND_LCHECKMSG_ZU(length, sizeof(*ap), "message length");
+ ND_ICHECKMSG_ZU("message length", length, <, sizeof(*ap));
ND_PRINT(" %u %s%s%s%s%shops %u id 0x%08x\n"
"\tdst %s seq %u src %s seq %u", length,
GET_U_1(ap->rreq_type) & RREQ_JOIN ? "[J]" : "",
@@ -296,7 +297,7 @@ aodv_v6_rrep(netdissect_options *ndo, const u_char *dat, u_int length)
u_int i;
const struct aodv_rrep6 *ap = (const struct aodv_rrep6 *)dat;
- ND_LCHECKMSG_ZU(length, sizeof(*ap), "message length");
+ ND_ICHECKMSG_ZU("message length", length, <, sizeof(*ap));
ND_PRINT(" %u %s%sprefix %u hops %u\n"
"\tdst %s dseq %u src %s %u ms", length,
GET_U_1(ap->rrep_type) & RREP_REPAIR ? "[R]" : "",
@@ -323,14 +324,14 @@ aodv_v6_rerr(netdissect_options *ndo, const u_char *dat, u_int length)
const struct aodv_rerr *ap = (const struct aodv_rerr *)dat;
const struct rerr_unreach6 *dp6;
- ND_LCHECKMSG_ZU(length, sizeof(*ap), "message length");
+ ND_ICHECKMSG_ZU("message length", length, <, sizeof(*ap));
ND_PRINT(" %s [items %u] [%u]:",
GET_U_1(ap->rerr_flags) & RERR_NODELETE ? "[D]" : "",
GET_U_1(ap->rerr_dc), length);
dp6 = (const struct rerr_unreach6 *)(const void *)(ap + 1);
i = length - sizeof(*ap);
for (dc = GET_U_1(ap->rerr_dc); dc != 0; dc--) {
- ND_LCHECKMSG_ZU(i, sizeof(*dp6), "remaining length");
+ ND_ICHECKMSG_ZU("remaining length", i, <, sizeof(*dp6));
ND_PRINT(" {%s}(%u)", GET_IP6ADDR_STRING(dp6->u_da),
GET_BE_U_4(dp6->u_ds));
dp6++;
diff --git a/print-atalk.c b/print-atalk.c
index 4e1fa3d2..57c65c09 100644
--- a/print-atalk.c
+++ b/print-atalk.c
@@ -166,7 +166,7 @@ llap_print(netdissect_options *ndo,
u_int hdrlen;
ndo->ndo_protocol = "llap";
- ND_LCHECKMSG_ZU(length, sizeof(*lp), "LLAP length");
+ ND_ICHECKMSG_ZU("LLAP length", length, <, sizeof(*lp));
lp = (const struct LAP *)bp;
bp += sizeof(*lp);
length -= sizeof(*lp);
@@ -175,7 +175,7 @@ llap_print(netdissect_options *ndo,
case lapShortDDP:
ndo->ndo_protocol = "sddp";
- ND_LCHECKMSG_U(length, ddpSSize, "SDDP length");
+ ND_ICHECKMSG_U("SDDP length", length, <, ddpSSize);
sdp = (const struct atShortDDP *)bp;
ND_PRINT("%s.%s",
ataddr_string(ndo, 0, GET_U_1(lp->src)),
@@ -192,7 +192,7 @@ llap_print(netdissect_options *ndo,
case lapDDP:
ndo->ndo_protocol = "ddp";
- ND_LCHECKMSG_U(length, ddpSize, "DDP length");
+ ND_ICHECKMSG_U("DDP length", length, <, ddpSize);
dp = (const struct atDDP *)bp;
snet = GET_BE_U_2(dp->srcNet);
ND_PRINT("%s.%s",
@@ -236,7 +236,7 @@ atalk_print(netdissect_options *ndo,
if(!ndo->ndo_eflag)
ND_PRINT("AT ");
- ND_LCHECK_U(length, ddpSize);
+ ND_ICHECK_U(length, <, ddpSize);
dp = (const struct atDDP *)bp;
snet = GET_BE_U_2(dp->srcNet);
ND_PRINT("%s.%s", ataddr_string(ndo, snet, GET_U_1(dp->srcNode)),
@@ -267,7 +267,7 @@ aarp_print(netdissect_options *ndo,
ndo->ndo_protocol = "aarp";
ND_PRINT("aarp ");
ap = (const struct aarp *)bp;
- ND_LCHECK_ZU(length, sizeof(*ap));
+ ND_ICHECK_ZU(length, <, sizeof(*ap));
ND_TCHECK_SIZE(ap);
if (GET_BE_U_2(ap->htype) == 1 &&
GET_BE_U_2(ap->ptype) == ETHERTYPE_ATALK &&
@@ -331,7 +331,7 @@ atp_print(netdissect_options *ndo,
uint32_t data;
ndo->ndo_protocol = "atp";
- ND_LCHECKMSG_ZU(length, sizeof(*ap), "ATP length");
+ ND_ICHECKMSG_ZU("ATP length", length, <, sizeof(*ap));
length -= sizeof(*ap);
control = GET_U_1(ap->control);
switch (control & 0xc0) {
@@ -459,7 +459,7 @@ nbp_print(netdissect_options *ndo,
u_int i;
/* must be room for at least one tuple */
- ND_LCHECKMSG_U(length, nbpHeaderSize + 8, "undersized-nbp");
+ ND_ICHECKMSG_U("undersized-nbp", length, <, nbpHeaderSize + 8);
length -= nbpHeaderSize;
control = GET_U_1(np->control);
ND_PRINT(" nbp-%s", tok2str(nbp_str, "0x%x", control & 0xf0));
diff --git a/print-egp.c b/print-egp.c
index bf9578db..04007b97 100644
--- a/print-egp.c
+++ b/print-egp.c
@@ -265,7 +265,7 @@ egp_print(netdissect_options *ndo,
ndo->ndo_protocol = "egp";
egp = (const struct egp_packet *)bp;
- ND_LCHECKMSG_ZU(length, sizeof(*egp), "packet length");
+ ND_ICHECKMSG_ZU("packet length", length, <, sizeof(*egp));
ND_TCHECK_SIZE(egp);
version = GET_U_1(egp->egp_version);
diff --git a/print-ether.c b/print-ether.c
index c47749c3..d20addbf 100644
--- a/print-ether.c
+++ b/print-ether.c
@@ -238,7 +238,7 @@ recurse:
*/
length_type = GET_BE_U_2(p);
- ND_LCHECK_U(caplen, 2);
+ ND_ICHECK_U(caplen, <, 2);
length -= 2;
caplen -= 2;
p += 2;
diff --git a/print-geneve.c b/print-geneve.c
index 4d5dda6b..7b77e191 100644
--- a/print-geneve.c
+++ b/print-geneve.c
@@ -117,7 +117,7 @@ geneve_opts_print(netdissect_options *ndo, const u_char *bp, u_int len)
uint8_t opt_type;
uint8_t opt_len;
- ND_LCHECKMSG_U(len, 4, "remaining options length");
+ ND_ICHECKMSG_U("remaining options length", len, <, 4);
ND_PRINT("%s", sep);
sep = ", ";
@@ -169,7 +169,7 @@ geneve_print(netdissect_options *ndo, const u_char *bp, u_int len)
ndo->ndo_protocol = "geneve";
ND_PRINT("Geneve");
- ND_LCHECK_U(len, 8);
+ ND_ICHECK_U(len, <, 8);
ver_opt = GET_U_1(bp);
bp += 1;
diff --git a/print-gre.c b/print-gre.c
index a28edf5c..136fb69d 100644
--- a/print-gre.c
+++ b/print-gre.c
@@ -83,7 +83,7 @@ gre_print(netdissect_options *ndo, const u_char *bp, u_int length)
ndo->ndo_protocol = "gre";
nd_print_protocol_caps(ndo);
- ND_LCHECK_U(length, 2);
+ ND_ICHECK_U(length, <, 2);
vers = GET_BE_U_2(bp) & GRE_VERS_MASK;
ND_PRINT("v%u",vers);
@@ -110,7 +110,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
u_int len = length;
uint16_t flags, prot;
- ND_LCHECK_U(len, 2);
+ ND_ICHECK_U(len, <, 2);
flags = GET_BE_U_2(bp);
if (ndo->ndo_vflag)
ND_PRINT(", Flags [%s]",
@@ -119,7 +119,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
len -= 2;
bp += 2;
- ND_LCHECK_U(len, 2);
+ ND_ICHECK_U(len, <, 2);
prot = GET_BE_U_2(bp);
len -= 2;
bp += 2;
@@ -127,28 +127,28 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
if ((flags & GRE_CP) | (flags & GRE_RP)) {
uint16_t sum;
- ND_LCHECK_U(len, 2);
+ ND_ICHECK_U(len, <, 2);
sum = GET_BE_U_2(bp);
if (ndo->ndo_vflag)
ND_PRINT(", sum 0x%x", sum);
bp += 2;
len -= 2;
- ND_LCHECK_U(len, 2);
+ ND_ICHECK_U(len, <, 2);
ND_PRINT(", off 0x%x", GET_BE_U_2(bp));
bp += 2;
len -= 2;
}
if (flags & GRE_KP) {
- ND_LCHECK_U(len, 4);
+ ND_ICHECK_U(len, <, 4);
ND_PRINT(", key=0x%x", GET_BE_U_4(bp));
bp += 4;
len -= 4;
}
if (flags & GRE_SP) {
- ND_LCHECK_U(len, 4);
+ ND_ICHECK_U(len, <, 4);
ND_PRINT(", seq %u", GET_BE_U_4(bp));
bp += 4;
len -= 4;
@@ -160,7 +160,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
uint8_t sreoff;
uint8_t srelen;
- ND_LCHECK_U(len, 4);
+ ND_ICHECK_U(len, <, 4);
af = GET_BE_U_2(bp);
sreoff = GET_U_1(bp + 2);
srelen = GET_U_1(bp + 3);
@@ -173,7 +173,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
if (!gre_sre_print(ndo, af, sreoff, srelen, bp, len))
goto invalid;
- ND_LCHECK_U(len, srelen);
+ ND_ICHECK_U(len, <, srelen);
bp += srelen;
len -= srelen;
}
@@ -227,7 +227,7 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
u_int len = length;
uint16_t flags, prot;
- ND_LCHECK_U(len, 2);
+ ND_ICHECK_U(len, <, 2);
flags = GET_BE_U_2(bp);
len -= 2;
bp += 2;
@@ -236,7 +236,7 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
ND_PRINT(", Flags [%s]",
bittok2str(gre_flag_values,"none",flags));
- ND_LCHECK_U(len, 2);
+ ND_ICHECK_U(len, <, 2);
prot = GET_BE_U_2(bp);
len -= 2;
bp += 2;
@@ -245,7 +245,7 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
if (flags & GRE_KP) {
uint32_t k;
- ND_LCHECK_U(len, 4);
+ ND_ICHECK_U(len, <, 4);
k = GET_BE_U_4(bp);
ND_PRINT(", call %u", k & 0xffff);
len -= 4;
@@ -253,14 +253,14 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
}
if (flags & GRE_SP) {
- ND_LCHECK_U(len, 4);
+ ND_ICHECK_U(len, <, 4);
ND_PRINT(", seq %u", GET_BE_U_4(bp));
bp += 4;
len -= 4;
}
if (flags & GRE_AP) {
- ND_LCHECK_U(len, 4);
+ ND_ICHECK_U(len, <, 4);
ND_PRINT(", ack %u", GET_BE_U_4(bp));
bp += 4;
len -= 4;
@@ -342,7 +342,7 @@ gre_sre_ip_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
}
while (srelen != 0) {
- ND_LCHECK_U(len, 4);
+ ND_ICHECK_U(len, <, 4);
ND_TCHECK_LEN(bp, sizeof(nd_ipv4));
addrtostr(bp, buf, sizeof(buf));
@@ -379,7 +379,7 @@ gre_sre_asn_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
}
while (srelen != 0) {
- ND_LCHECK_U(len, 2);
+ ND_ICHECK_U(len, <, 2);
ND_PRINT(" %s%x",
((bp - up) == sreoff) ? "*" : "", GET_BE_U_2(bp));
diff --git a/print-ipx.c b/print-ipx.c
index f8c0ce7c..73a79aab 100644
--- a/print-ipx.c
+++ b/print-ipx.c
@@ -156,7 +156,7 @@ ipx_sap_print(netdissect_options *ndo, const u_char *ipx, u_int length)
int command, i;
command = GET_BE_U_2(ipx);
- ND_LCHECK_U(length, 2);
+ ND_ICHECK_U(length, <, 2);
ipx += 2;
length -= 2;
@@ -230,7 +230,7 @@ ipx_rip_print(netdissect_options *ndo, const u_char *ipx, u_int length)
int command, i;
command = GET_BE_U_2(ipx);
- ND_LCHECK_U(length, 2);
+ ND_ICHECK_U(length, <, 2);
ipx += 2;
length -= 2;
diff --git a/print-juniper.c b/print-juniper.c
index a068a6bf..13d8f837 100644
--- a/print-juniper.c
+++ b/print-juniper.c
@@ -1331,7 +1331,8 @@ juniper_parse_header(netdissect_options *ndo,
/* sanity checks */
if (tlv_type == 0 || tlv_len == 0)
break;
- ND_LCHECK_U(extension_length, tlv_len + JUNIPER_EXT_TLV_OVERHEAD);
+ ND_ICHECK_U(extension_length, <,
+ tlv_len + JUNIPER_EXT_TLV_OVERHEAD);
if (ndo->ndo_vflag > 1)
ND_PRINT("\n\t %s Extension TLV #%u, length %u, value ",
diff --git a/print-l2tp.c b/print-l2tp.c
index 024705f8..89215505 100644
--- a/print-l2tp.c
+++ b/print-l2tp.c
@@ -577,7 +577,7 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, u_int length)
len = GET_BE_U_2(dat) & L2TP_AVP_HDR_LEN_MASK;
/* If it is not long enough to contain the header, we'll give up. */
- ND_LCHECKMSG_U(len, 6, "AVP length");
+ ND_ICHECKMSG_U("AVP length", len, <, 6);
/* If it goes past the end of the remaining length of the packet,
we'll give up. */
diff --git a/print-olsr.c b/print-olsr.c
index df796d95..dca323f6 100644
--- a/print-olsr.c
+++ b/print-olsr.c
@@ -325,7 +325,7 @@ olsr_print(netdissect_options *ndo,
nd_print_protocol_caps(ndo);
ND_PRINT("v%u", (is_ipv6) ? 6 : 4);
- ND_LCHECKMSG_ZU(length, sizeof(struct olsr_common), "packet length");
+ ND_ICHECKMSG_ZU("packet length", length, <, sizeof(struct olsr_common));
ptr.common = (const struct olsr_common *)tptr;
length = ND_MIN(length, GET_BE_U_2(ptr.common->packet_len));
@@ -417,7 +417,8 @@ olsr_print(netdissect_options *ndo,
switch (msg_type) {
case OLSR_HELLO_MSG:
case OLSR_HELLO_LQ_MSG:
- ND_LCHECKMSG_ZU(msg_tlen, sizeof(struct olsr_hello), "message length");
+ ND_ICHECKMSG_ZU("message length", msg_tlen, <,
+ sizeof(struct olsr_hello));
ptr.hello = (const struct olsr_hello *)msg_data;
ND_PRINT("\n\t hello-time %.3fs, MPR willingness %u",
@@ -475,7 +476,8 @@ olsr_print(netdissect_options *ndo,
case OLSR_TC_MSG:
case OLSR_TC_LQ_MSG:
- ND_LCHECKMSG_ZU(msg_tlen, sizeof(struct olsr_tc), "message length");
+ ND_ICHECKMSG_ZU("message length", msg_tlen, <,
+ sizeof(struct olsr_tc));
ND_TCHECK_LEN(msg_data, sizeof(struct olsr_tc));
ptr.tc = (const struct olsr_tc *)msg_data;
@@ -605,7 +607,7 @@ olsr_print(netdissect_options *ndo,
int name_entries_valid;
u_int i;
- ND_LCHECKMSG_U(msg_tlen, 4, "message length");
+ ND_ICHECKMSG_U("message length", msg_tlen, <, 4);
name_entries = GET_BE_U_2(msg_data + 2);
addr_size = 4;
@@ -654,8 +656,8 @@ olsr_print(netdissect_options *ndo,
if (name_entry_len%4 != 0)
name_entry_padding = 4-(name_entry_len%4);
- ND_LCHECKMSG_U(msg_tlen, addr_size + name_entry_len + name_entry_padding,
- "name entry length");
+ ND_ICHECKMSG_U("name entry length", msg_tlen, <,
+ addr_size + name_entry_len + name_entry_padding);
ND_TCHECK_LEN(msg_data,
addr_size + name_entry_len + name_entry_padding);
diff --git a/print-ptp.c b/print-ptp.c
index f4ccbe9d..c4ff0204 100644
--- a/print-ptp.c
+++ b/print-ptp.c
@@ -436,7 +436,7 @@ ptp_print(netdissect_options *ndo, const u_char *bp, u_int length)
u_int vers;
ndo->ndo_protocol = "ptp";
- ND_LCHECK_U(length, PTP_HDR_LEN);
+ ND_ICHECK_U(length, <, PTP_HDR_LEN);
vers = GET_BE_U_2(bp) & PTP_VERS_MASK;
ND_PRINT("PTPv%u",vers);
switch(vers) {
diff --git a/print-rip.c b/print-rip.c
index 8aea1f8a..265222a1 100644
--- a/print-rip.c
+++ b/print-rip.c
@@ -195,7 +195,7 @@ rip_entry_print_v1(netdissect_options *ndo, const u_char *p,
const struct rip_netinfo_v1 *ni = (const struct rip_netinfo_v1 *)p;
/* RFC 1058 */
- ND_LCHECKMSG_U(remaining, RIP_ROUTELEN, "remaining data length");
+ ND_ICHECKMSG_U("remaining data length", remaining, <, RIP_ROUTELEN);
ND_TCHECK_SIZE(ni);
family = GET_BE_U_2(ni->rip_family);
if (family != BSD_AFNUM_INET && family != 0) {
@@ -232,7 +232,7 @@ rip_entry_print_v2(netdissect_options *ndo, const u_char *p,
u_short family;
const struct rip_netinfo_v2 *ni;
- ND_LCHECKMSG_ZU(remaining, sizeof(*eh), "remaining data length");
+ ND_ICHECKMSG_ZU("remaining data length", remaining, <, sizeof(*eh));
ND_TCHECK_SIZE(eh);
family = GET_BE_U_2(eh->rip_family);
if (family == 0xFFFF) { /* variable-sized authentication structures */
@@ -247,7 +247,8 @@ rip_entry_print_v2(netdissect_options *ndo, const u_char *p,
const struct rip_auth_crypto_v2 *ch;
ch = (const struct rip_auth_crypto_v2 *)p;
- ND_LCHECKMSG_ZU(remaining, sizeof(*ch), "remaining data length");
+ ND_ICHECKMSG_ZU("remaining data length", remaining,
+ <, sizeof(*ch));
ND_PRINT("\n\t Auth header:");
ND_PRINT(" Packet Len %u,",
GET_BE_U_2(ch->rip_packet_len));
@@ -272,7 +273,8 @@ rip_entry_print_v2(netdissect_options *ndo, const u_char *p,
print_unknown_data(ndo, p + sizeof(*eh), "\n\t ", RIP_ROUTELEN - sizeof(*eh));
} else { /* BSD_AFNUM_INET or AFI 0 */
ni = (const struct rip_netinfo_v2 *)p;
- ND_LCHECKMSG_ZU(remaining, sizeof(*ni), "remaining data length");
+ ND_ICHECKMSG_ZU("remaining data length", remaining, <,
+ sizeof(*ni));
ND_PRINT("\n\t AFI %s, %15s/%-2d, tag 0x%04x, metric: %u, next-hop: ",
tok2str(bsd_af_values, "%u", family),
GET_IPADDR_STRING(ni->rip_dest),
@@ -298,7 +300,7 @@ rip_print(netdissect_options *ndo,
unsigned entry_size;
ndo->ndo_protocol = "rip";
- ND_LCHECKMSG_ZU(len, sizeof(*rp), "packet length");
+ ND_ICHECKMSG_ZU("packet length", len, <, sizeof(*rp));
rp = (const struct rip *)p;
@@ -333,7 +335,8 @@ rip_print(netdissect_options *ndo,
/* Error */
goto invalid;
}
- ND_LCHECKMSG_U(len, entry_size, "remaining entries length");
+ ND_ICHECKMSG_U("remaining entries length",
+ len, <, entry_size);
p += entry_size;
len -= entry_size;
}
@@ -347,7 +350,8 @@ rip_print(netdissect_options *ndo,
/* Error */
goto invalid;
}
- ND_LCHECKMSG_U(len, entry_size, "remaining entries length");
+ ND_ICHECKMSG_U("remaining entries length",
+ len, <, entry_size);
p += entry_size;
len -= entry_size;
}
diff --git a/print-rsvp.c b/print-rsvp.c
index 86744e06..df9edc6c 100644
--- a/print-rsvp.c
+++ b/print-rsvp.c
@@ -519,7 +519,7 @@ rsvp_intserv_print(netdissect_options *ndo,
uint32_t i;
} bw;
- ND_LCHECK_U(obj_tlen, 4);
+ ND_ICHECK_U(obj_tlen, <, 4);
parameter_id = GET_U_1(tptr);
parameter_length = GET_BE_U_2(tptr + 2)<<2; /* convert wordcount to bytecount */
@@ -529,7 +529,7 @@ rsvp_intserv_print(netdissect_options *ndo,
parameter_length,
GET_U_1(tptr + 1));
- ND_LCHECK_U(obj_tlen, parameter_length + 4);
+ ND_ICHECK_U(obj_tlen, <, parameter_length + 4);
switch(parameter_id) { /* parameter_id */
case 4:
@@ -1252,7 +1252,7 @@ rsvp_obj_print(netdissect_options *ndo,
* each iteration subobj_len may happen to be a multiple of 1
* and test it and total_subobj_len respectively.
*/
- ND_LCHECK_U(total_subobj_len, 4);
+ ND_ICHECK_U(total_subobj_len, <, 4);
subobj_len = GET_BE_U_2(obj_tptr);
subobj_type = (GET_BE_U_2(obj_tptr + 2))>>8;
af = (GET_BE_U_2(obj_tptr + 2))&0x00FF;
diff --git a/print-sflow.c b/print-sflow.c
index ecf3caa7..ff50c555 100644
--- a/print-sflow.c
+++ b/print-sflow.c
@@ -891,7 +891,7 @@ sflow_print(netdissect_options *ndo,
len);
/* skip Common header */
- ND_LCHECK_ZU(tlen, sizeof(struct sflow_v6_datagram_t));
+ ND_ICHECK_ZU(tlen, <, sizeof(struct sflow_v6_datagram_t));
tptr += sizeof(struct sflow_v6_datagram_t);
tlen -= sizeof(struct sflow_v6_datagram_t);
}
diff --git a/print-udp.c b/print-udp.c
index d5891de6..aa132678 100644
--- a/print-udp.c
+++ b/print-udp.c
@@ -369,7 +369,7 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
if (ndo->ndo_packettype != PT_RPC)
udpipaddr_print(ndo, ip, sport, dport);
- ND_LCHECKMSG_ZU(length, sizeof(struct udphdr), "undersized-udp");
+ ND_ICHECKMSG_ZU("undersized-udp", length, <, sizeof(struct udphdr));
ulen = GET_BE_U_2(up->uh_ulen);
udp_sum = GET_BE_U_2(up->uh_sum);
/*
@@ -379,7 +379,8 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
*/
if (ulen == 0 && length > 65535)
ulen = length;
- ND_LCHECKMSG_ZU(ulen, sizeof(struct udphdr), "undersized-udplength");
+ ND_ICHECKMSG_ZU("undersized-udplength", ulen, <,
+ sizeof(struct udphdr));
ulen -= sizeof(struct udphdr);
length -= sizeof(struct udphdr);
if (ulen < length)
diff --git a/print-zep.c b/print-zep.c
index fd74368c..7186f74a 100644
--- a/print-zep.c
+++ b/print-zep.c
@@ -123,7 +123,7 @@ zep_print(netdissect_options *ndo,
if (version == 1) {
/* ZEP v1 packet. */
- ND_LCHECK_U(len, 16);
+ ND_ICHECK_U(len, <, 16);
ND_PRINT("Channel ID %u, Device ID 0x%04x, ",
GET_U_1(bp + 3), GET_BE_U_2(bp + 4));
if (GET_U_1(bp + 6))
@@ -139,7 +139,7 @@ zep_print(netdissect_options *ndo,
/* ZEP v2 packet. */
if (GET_U_1(bp + 3) == 2) {
/* ZEP v2 ack. */
- ND_LCHECK_U(len, 8);
+ ND_ICHECK_U(len, <, 8);
seq_no = GET_BE_U_4(bp + 4);
ND_PRINT("ACK, seq# = %u", seq_no);
inner_len = 0;
@@ -147,7 +147,7 @@ zep_print(netdissect_options *ndo,
len -= 8;
} else {
/* ZEP v2 data, or some other. */
- ND_LCHECK_U(len, 32);
+ ND_ICHECK_U(len, <, 32);
ND_PRINT("Type %u, Channel ID %u, Device ID 0x%04x, ",
GET_U_1(bp + 3), GET_U_1(bp + 4),
GET_BE_U_2(bp + 5));