summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2020-09-05 21:56:50 +0200
committerFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2020-09-08 14:14:13 +0200
commitaad6ac30ce7904f688226dbc61021ca4f907274f (patch)
tree76ffb3367a34d7e5225fa1bc0a75aa6406118b6d
parentcbe18055349fa44ac8348c56834c32586e0a81ab (diff)
downloadtcpdump-aad6ac30ce7904f688226dbc61021ca4f907274f.tar.gz
Remove some now redundant ND_TCHECK_4() calls
ND_TCHECK_4(e). They are redundant because they are followed by a GET_IPADDR_STRING(e) call, same e, which do the bounds check. Remove unused 'trunc' labels and associated codes. Update the output of a test accordingly.
-rw-r--r--print-ahcp.c1
-rw-r--r--print-bgp.c4
-rw-r--r--print-bootp.c4
-rw-r--r--print-cdp.c1
-rw-r--r--print-dvmrp.c2
-rw-r--r--print-hsrp.c1
-rw-r--r--print-icmp.c2
-rw-r--r--print-igmp.c6
-rw-r--r--print-ip.c4
-rw-r--r--print-lisp.c1
-rw-r--r--print-openflow-1.0.c4
-rw-r--r--print-ospf.c9
-rw-r--r--print-ospf6.c4
-rw-r--r--print-pim.c2
-rw-r--r--print-ppp.c3
-rw-r--r--tests/ip_printroute_asan.out3
16 files changed, 1 insertions, 50 deletions
diff --git a/print-ahcp.c b/print-ahcp.c
index 2a1eb1ab..d5b2cc0d 100644
--- a/print-ahcp.c
+++ b/print-ahcp.c
@@ -171,7 +171,6 @@ ahcp_ipv4_addresses_print(netdissect_options *ndo, const u_char *cp, const u_cha
while (cp < ep) {
if (cp + 4 > ep)
goto invalid;
- ND_TCHECK_4(cp);
ND_PRINT("%s%s", sep, GET_IPADDR_STRING(cp));
cp += 4;
sep = ", ";
diff --git a/print-bgp.c b/print-bgp.c
index 0abb7001..0e45ee3e 100644
--- a/print-bgp.c
+++ b/print-bgp.c
@@ -1980,7 +1980,6 @@ bgp_attr_print(netdissect_options *ndo,
if (len != 4)
ND_PRINT("invalid len");
else {
- ND_TCHECK_4(tptr);
ND_PRINT("%s", GET_IPADDR_STRING(tptr));
}
break;
@@ -2063,7 +2062,6 @@ bgp_attr_print(netdissect_options *ndo,
ND_PRINT("invalid len");
break;
}
- ND_TCHECK_4(tptr);
ND_PRINT("%s",GET_IPADDR_STRING(tptr));
break;
case BGPTYPE_CLUSTER_LIST:
@@ -2072,7 +2070,6 @@ bgp_attr_print(netdissect_options *ndo,
break;
}
while (tlen != 0) {
- ND_TCHECK_4(tptr);
if (tlen < 4)
goto trunc;
ND_PRINT("%s%s",
@@ -2382,7 +2379,6 @@ bgp_attr_print(netdissect_options *ndo,
GET_IPADDR_STRING(tptr+4));
break;
case BGP_PMSI_TUNNEL_INGRESS:
- ND_TCHECK_4(tptr);
ND_PRINT("\n\t Tunnel-Endpoint %s",
GET_IPADDR_STRING(tptr));
break;
diff --git a/print-bootp.c b/print-bootp.c
index a2f1929a..1ee979f5 100644
--- a/print-bootp.c
+++ b/print-bootp.c
@@ -322,22 +322,18 @@ bootp_print(netdissect_options *ndo,
ND_PRINT(" (0x%04x)", GET_BE_U_2(bp->bp_flags));
/* Client's ip address */
- ND_TCHECK_4(bp->bp_ciaddr);
if (GET_IPV4_TO_NETWORK_ORDER(bp->bp_ciaddr))
ND_PRINT("\n\t Client-IP %s", GET_IPADDR_STRING(bp->bp_ciaddr));
/* 'your' ip address (bootp client) */
- ND_TCHECK_4(bp->bp_yiaddr);
if (GET_IPV4_TO_NETWORK_ORDER(bp->bp_yiaddr))
ND_PRINT("\n\t Your-IP %s", GET_IPADDR_STRING(bp->bp_yiaddr));
/* Server's ip address */
- ND_TCHECK_4(bp->bp_siaddr);
if (GET_IPV4_TO_NETWORK_ORDER(bp->bp_siaddr))
ND_PRINT("\n\t Server-IP %s", GET_IPADDR_STRING(bp->bp_siaddr));
/* Gateway's ip address */
- ND_TCHECK_4(bp->bp_giaddr);
if (GET_IPV4_TO_NETWORK_ORDER(bp->bp_giaddr))
ND_PRINT("\n\t Gateway-IP %s", GET_IPADDR_STRING(bp->bp_giaddr));
diff --git a/print-cdp.c b/print-cdp.c
index e1e7d71b..0ab646e5 100644
--- a/print-cdp.c
+++ b/print-cdp.c
@@ -337,7 +337,6 @@ cdp_print_addr(netdissect_options *ndo,
*/
p += 3;
- ND_TCHECK_4(p);
if (p + 4 > endp)
goto trunc;
ND_PRINT("IPv4 (%u) %s", num, GET_IPADDR_STRING(p));
diff --git a/print-dvmrp.c b/print-dvmrp.c
index 8ed95a8d..abda58fa 100644
--- a/print-dvmrp.c
+++ b/print-dvmrp.c
@@ -237,7 +237,6 @@ print_probe(netdissect_options *ndo,
return (0);
while ((len > 0) && (bp < ep)) {
- ND_TCHECK_4(bp);
ND_PRINT("\n\tneighbor %s", GET_IPADDR_STRING(bp));
bp += 4; len -= 4;
}
@@ -268,7 +267,6 @@ print_neighbors(netdissect_options *ndo,
bp++;
len -= 7;
while (--ncount >= 0) {
- ND_TCHECK_4(bp);
ND_PRINT(" [%s ->", GET_IPADDR_STRING(laddr));
ND_PRINT(" %s, (%u/%u)]",
GET_IPADDR_STRING(bp), metric, thresh);
diff --git a/print-hsrp.c b/print-hsrp.c
index b4e02f55..3b6a1ff8 100644
--- a/print-hsrp.c
+++ b/print-hsrp.c
@@ -114,7 +114,6 @@ hsrp_print(netdissect_options *ndo, const u_char *bp, u_int len)
if (GET_U_1(hp->hsrp_reserved) != 0) {
ND_PRINT("[reserved=%u!] ", GET_U_1(hp->hsrp_reserved));
}
- ND_TCHECK_4(hp->hsrp_virtaddr);
ND_PRINT("addr=%s", GET_IPADDR_STRING(hp->hsrp_virtaddr));
if (ndo->ndo_vflag) {
ND_PRINT(" hellotime=");
diff --git a/print-icmp.c b/print-icmp.c
index 020e433e..59b56c6a 100644
--- a/print-icmp.c
+++ b/print-icmp.c
@@ -333,7 +333,6 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
break;
case ICMP_UNREACH:
- ND_TCHECK_4(dp->icmp_ip.ip_dst);
switch (icmp_code) {
case ICMP_UNREACH_NET:
@@ -481,7 +480,6 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
break;
case ICMP_REDIRECT:
- ND_TCHECK_4(dp->icmp_ip.ip_dst);
switch (icmp_code) {
case ICMP_REDIRECT_NET:
diff --git a/print-igmp.c b/print-igmp.c
index 2c83fb8a..8c5bc15d 100644
--- a/print-igmp.c
+++ b/print-igmp.c
@@ -288,13 +288,11 @@ igmp_print(netdissect_options *ndo,
}
break;
case 0x12:
- ND_TCHECK_4(bp + 4);
ND_PRINT("igmp v1 report %s", GET_IPADDR_STRING(bp + 4));
if (len != 8)
ND_PRINT(" [len %u]", len);
break;
case 0x16:
- ND_TCHECK_4(bp + 4);
ND_PRINT("igmp v2 report %s", GET_IPADDR_STRING(bp + 4));
break;
case 0x22:
@@ -302,7 +300,6 @@ igmp_print(netdissect_options *ndo,
print_igmpv3_report(ndo, bp, len);
break;
case 0x17:
- ND_TCHECK_4(bp + 4);
ND_PRINT("igmp leave %s", GET_IPADDR_STRING(bp + 4));
break;
case 0x13:
@@ -334,7 +331,4 @@ igmp_print(netdissect_options *ndo,
if (in_cksum(vec, 1))
ND_PRINT(" bad igmp cksum %x!", GET_BE_U_2(bp + 2));
}
- return;
-trunc:
- nd_print_trunc(ndo);
}
diff --git a/print-ip.c b/print-ip.c
index 47850f31..8dab9443 100644
--- a/print-ip.c
+++ b/print-ip.c
@@ -71,15 +71,11 @@ ip_printroute(netdissect_options *ndo,
ND_PRINT(" [bad ptr %u]", GET_U_1(cp + 2));
for (len = 3; len < length; len += 4) {
- ND_TCHECK_4(cp + len);
ND_PRINT(" %s", GET_IPADDR_STRING(cp + len));
if (ptr > len)
ND_PRINT(",");
}
return (0);
-
-trunc:
- return (-1);
}
/*
diff --git a/print-lisp.c b/print-lisp.c
index 27cafb30..6e9cbd14 100644
--- a/print-lisp.c
+++ b/print-lisp.c
@@ -307,7 +307,6 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
switch (eid_afi) {
case IPv4_AFI:
- ND_TCHECK_4(packet_iterator + packet_offset);
ND_PRINT(" EID %s/%u,",
GET_IPADDR_STRING(packet_iterator + packet_offset),
mask_len);
diff --git a/print-openflow-1.0.c b/print-openflow-1.0.c
index 21a1cbe9..6c224b73 100644
--- a/print-openflow-1.0.c
+++ b/print-openflow-1.0.c
@@ -808,7 +808,6 @@ of10_bsn_message_print(netdissect_options *ndo,
/* pad */
cp += 3;
/* mask */
- ND_TCHECK_4(cp);
ND_PRINT(", mask %s", GET_IPADDR_STRING(cp));
cp += 4;
break;
@@ -1378,13 +1377,11 @@ of10_match_print(netdissect_options *ndo,
ND_TCHECK_2(cp);
cp += 2;
/* nw_src */
- ND_TCHECK_4(cp);
nw_bits = (wildcards & OFPFW_NW_SRC_MASK) >> OFPFW_NW_SRC_SHIFT;
if (nw_bits < 32)
ND_PRINT("%smatch nw_src %s/%u", pfx, GET_IPADDR_STRING(cp), 32 - nw_bits);
cp += 4;
/* nw_dst */
- ND_TCHECK_4(cp);
nw_bits = (wildcards & OFPFW_NW_DST_MASK) >> OFPFW_NW_DST_SHIFT;
if (nw_bits < 32)
ND_PRINT("%smatch nw_dst %s/%u", pfx, GET_IPADDR_STRING(cp), 32 - nw_bits);
@@ -1514,7 +1511,6 @@ of10_actions_print(netdissect_options *ndo,
case OFPAT_SET_NW_SRC:
case OFPAT_SET_NW_DST:
/* nw_addr */
- ND_TCHECK_4(cp);
ND_PRINT(", nw_addr %s", GET_IPADDR_STRING(cp));
cp += 4;
break;
diff --git a/print-ospf.c b/print-ospf.c
index a0474a39..09876377 100644
--- a/print-ospf.c
+++ b/print-ospf.c
@@ -491,7 +491,6 @@ ospf_te_lsa_print(netdissect_options *ndo,
ND_PRINT("\n\t TLV length %u < 4", tlv_length);
return -1;
}
- ND_TCHECK_4(tptr);
ND_PRINT(", %s", GET_IPADDR_STRING(tptr));
break;
@@ -698,7 +697,6 @@ ospf_print_lsa(netdissect_options *ndo,
break;
case LS_TYPE_NETWORK:
- ND_TCHECK_4(lsap->lsa_un.un_nla.nla_mask);
ND_PRINT("\n\t Mask %s\n\t Connected Routers:",
GET_IPADDR_STRING(lsap->lsa_un.un_nla.nla_mask));
ap = lsap->lsa_un.un_nla.nla_router;
@@ -766,11 +764,9 @@ ospf_print_lsa(netdissect_options *ndo,
else
ND_PRINT(" %u", (ul & ASLA_MASK_METRIC));
- ND_TCHECK_4(almp->asla_forward);
if (GET_IPV4_TO_NETWORK_ORDER(almp->asla_forward) != 0) {
ND_PRINT(", forward %s", GET_IPADDR_STRING(almp->asla_forward));
}
- ND_TCHECK_4(almp->asla_tag);
if (GET_IPV4_TO_NETWORK_ORDER(almp->asla_tag) != 0) {
ND_PRINT(", tag %s", GET_IPADDR_STRING(almp->asla_tag));
}
@@ -782,7 +778,6 @@ ospf_print_lsa(netdissect_options *ndo,
/* Multicast extensions as of 23 July 1991 */
mcp = lsap->lsa_un.un_mcla;
while ((const u_char *)mcp < ls_end) {
- ND_TCHECK_4(mcp->mcla_vid);
switch (GET_BE_U_4(mcp->mcla_vtype)) {
case MCLA_VERTEX_ROUTER:
@@ -999,12 +994,10 @@ ospf_decode_v2(netdissect_options *ndo,
GET_IPADDR_STRING(op->ospf_hello.hello_mask),
GET_U_1(op->ospf_hello.hello_priority));
- ND_TCHECK_4(op->ospf_hello.hello_dr);
if (GET_IPV4_TO_NETWORK_ORDER(op->ospf_hello.hello_dr) != 0)
ND_PRINT("\n\t Designated Router %s",
GET_IPADDR_STRING(op->ospf_hello.hello_dr));
- ND_TCHECK_4(op->ospf_hello.hello_bdr);
if (GET_IPV4_TO_NETWORK_ORDER(op->ospf_hello.hello_bdr) != 0)
ND_PRINT(", Backup Designated Router %s",
GET_IPADDR_STRING(op->ospf_hello.hello_bdr));
@@ -1134,10 +1127,8 @@ ospf_print(netdissect_options *ndo,
dataend = bp + length;
}
- ND_TCHECK_4(op->ospf_routerid);
ND_PRINT("\n\tRouter-ID %s", GET_IPADDR_STRING(op->ospf_routerid));
- ND_TCHECK_4(op->ospf_areaid);
if (GET_IPV4_TO_NETWORK_ORDER(op->ospf_areaid) != 0)
ND_PRINT(", Area %s", GET_IPADDR_STRING(op->ospf_areaid));
else
diff --git a/print-ospf6.c b/print-ospf6.c
index 01a35d56..5e4f163d 100644
--- a/print-ospf6.c
+++ b/print-ospf6.c
@@ -388,7 +388,6 @@ ospf6_print_lshdr(netdissect_options *ndo,
{
if ((const u_char *)(lshp + 1) > dataend)
goto trunc;
- ND_TCHECK_4(lshp->ls_router);
ND_PRINT("\n\t Advertising Router %s, seq 0x%08x, age %us, length %u",
GET_IPADDR_STRING(lshp->ls_router),
@@ -617,7 +616,6 @@ ospf6_print_lsa(netdissect_options *ndo,
if (lsa_length < sizeof (uint32_t))
return (1);
lsa_length -= sizeof (uint32_t);
- ND_TCHECK_4(tptr);
ND_PRINT(" tag %s",
GET_IPADDR_STRING(tptr));
tptr += sizeof(uint32_t);
@@ -627,7 +625,6 @@ ospf6_print_lsa(netdissect_options *ndo,
if (lsa_length < sizeof (uint32_t))
return (1);
lsa_length -= sizeof (uint32_t);
- ND_TCHECK_4(tptr);
ND_PRINT(" RefLSID: %s",
GET_IPADDR_STRING(tptr));
tptr += sizeof(uint32_t);
@@ -980,7 +977,6 @@ ospf6_print(netdissect_options *ndo,
}
dataend = bp + datalen;
- ND_TCHECK_4(op->ospf6_routerid);
ND_PRINT("\n\tRouter-ID %s", GET_IPADDR_STRING(op->ospf6_routerid));
if (GET_BE_U_4(op->ospf6_areaid) != 0)
diff --git a/print-pim.c b/print-pim.c
index 1e63062e..186f84b5 100644
--- a/print-pim.c
+++ b/print-pim.c
@@ -410,7 +410,6 @@ cisco_autorp_print(netdissect_options *ndo,
if (len < 4)
goto trunc;
- ND_TCHECK_4(bp);
ND_PRINT(" RP %s", GET_IPADDR_STRING(bp));
bp += 4;
len -= 4;
@@ -913,7 +912,6 @@ pimv2_print(netdissect_options *ndo,
ip = (const struct ip *)bp;
switch (IP_V(ip)) {
case 0: /* Null header */
- ND_TCHECK_4(ip->ip_dst);
ND_PRINT("IP-Null-header %s > %s",
GET_IPADDR_STRING(ip->ip_src),
GET_IPADDR_STRING(ip->ip_dst));
diff --git a/print-ppp.c b/print-ppp.c
index 759b06b1..fe036247 100644
--- a/print-ppp.c
+++ b/print-ppp.c
@@ -731,7 +731,6 @@ print_lcp_config_options(netdissect_options *ndo,
ND_PRINT(" (length bogus, should be = 7)");
return 0;
}
- ND_TCHECK_4(p + 3);
ND_PRINT(": IPv4 %s", GET_IPADDR_STRING(p + 3));
break;
case MEDCLASS_MAC:
@@ -1038,7 +1037,6 @@ print_ipcp_config_options(netdissect_options *ndo,
ND_PRINT(" (length bogus, should be = 10)");
return len;
}
- ND_TCHECK_4(p + 6);
ND_PRINT(": src %s, dst %s",
GET_IPADDR_STRING(p + 2),
GET_IPADDR_STRING(p + 6));
@@ -1124,7 +1122,6 @@ print_ipcp_config_options(netdissect_options *ndo,
ND_PRINT(" (length bogus, should be = 6)");
return 0;
}
- ND_TCHECK_4(p + 2);
ND_PRINT(": %s", GET_IPADDR_STRING(p + 2));
break;
default:
diff --git a/tests/ip_printroute_asan.out b/tests/ip_printroute_asan.out
index 181476fb..cc181ad4 100644
--- a/tests/ip_printroute_asan.out
+++ b/tests/ip_printroute_asan.out
@@ -1,2 +1 @@
- 1 11:22:39.003332 IP (tos 0x0, ttl 254, id 25615, offset 65480, flags [DF, rsvd], proto UDP (17), length 32768, options (LSRR [bad length 25] [bad ptr 15] 103.103.103.0, 0.172.0.116, 0.16.36.36, 16.0.36.2 14.9.36.4 [truncated-option]))
- 251.73.86.0 > 0.172.128.5: [|ip]
+ 1 11:22:39.003332 IP (tos 0x0, ttl 254, id 25615, offset 65480, flags [DF, rsvd], proto UDP (17), length 32768, options (LSRR [bad length 25] [bad ptr 15] 103.103.103.0, 0.172.0.116, 0.16.36.36, 16.0.36.2 14.9.36.4 [|ip]