mirror of
https://github.com/the-tcpdump-group/tcpdump.git
synced 2024-11-27 12:03:44 +08:00
Remove some now redundant ND_TCHECK_LEN(e, sizeof(nd_ipv4)) calls
They are redundant because they are followed by a GET_IPADDR_STRING(e) call, same e, which do the bounds check. Remove unused 'trunc' label(s) and associated code(s).
This commit is contained in:
parent
aad6ac30ce
commit
3b8ff4bf0d
@ -684,7 +684,6 @@ bgp_vpn_ip_print(netdissect_options *ndo,
|
||||
|
||||
switch(addr_length) {
|
||||
case (sizeof(nd_ipv4) << 3): /* 32 */
|
||||
ND_TCHECK_LEN(pptr, sizeof(nd_ipv4));
|
||||
snprintf(pos, sizeof(addr), "%s", GET_IPADDR_STRING(pptr));
|
||||
break;
|
||||
case (sizeof(nd_ipv6) << 3): /* 128 */
|
||||
@ -696,7 +695,6 @@ bgp_vpn_ip_print(netdissect_options *ndo,
|
||||
}
|
||||
pos += strlen(pos);
|
||||
|
||||
trunc:
|
||||
*(pos) = '\0';
|
||||
return (addr);
|
||||
}
|
||||
@ -1116,13 +1114,10 @@ decode_mdt_vpn_nlri(netdissect_options *ndo,
|
||||
pptr += 8;
|
||||
|
||||
/* IPv4 address */
|
||||
ND_TCHECK_LEN(pptr, sizeof(nd_ipv4));
|
||||
vpn_ip = pptr;
|
||||
pptr += sizeof(nd_ipv4);
|
||||
|
||||
/* MDT Group Address */
|
||||
ND_TCHECK_LEN(pptr, sizeof(nd_ipv4));
|
||||
|
||||
snprintf(buf, buflen, "RD: %s, VPN IP Address: %s, MC Group Address: %s",
|
||||
bgp_vpn_rd_print(ndo, rd), GET_IPADDR_STRING(vpn_ip), GET_IPADDR_STRING(pptr));
|
||||
|
||||
@ -2123,7 +2118,6 @@ bgp_attr_print(netdissect_options *ndo,
|
||||
tlen -= tnhlen;
|
||||
tnhlen = 0;
|
||||
} else {
|
||||
ND_TCHECK_LEN(tptr, sizeof(nd_ipv4));
|
||||
ND_PRINT("%s",GET_IPADDR_STRING(tptr));
|
||||
tptr += sizeof(nd_ipv4);
|
||||
tnhlen -= sizeof(nd_ipv4);
|
||||
@ -2192,7 +2186,6 @@ bgp_attr_print(netdissect_options *ndo,
|
||||
tlen -= tnhlen;
|
||||
tnhlen = 0;
|
||||
} else {
|
||||
ND_TCHECK_LEN(tptr, sizeof(nd_ipv4));
|
||||
ND_PRINT("%s", GET_IPADDR_STRING(tptr));
|
||||
tptr += (sizeof(nd_ipv4));
|
||||
tlen -= (sizeof(nd_ipv4));
|
||||
|
@ -3236,7 +3236,6 @@ isis_print(netdissect_options *ndo,
|
||||
case ISIS_TLV_TE_ROUTER_ID:
|
||||
if (tlen < sizeof(nd_ipv4))
|
||||
goto tlv_trunc;
|
||||
ND_TCHECK_LEN(pptr, sizeof(nd_ipv4));
|
||||
ND_PRINT("\n\t Traffic Engineering Router ID: %s", GET_IPADDR_STRING(pptr));
|
||||
break;
|
||||
|
||||
@ -3244,7 +3243,6 @@ isis_print(netdissect_options *ndo,
|
||||
while (tlen != 0) {
|
||||
if (tlen < sizeof(nd_ipv4))
|
||||
goto tlv_trunc;
|
||||
ND_TCHECK_LEN(tptr, sizeof(nd_ipv4));
|
||||
ND_PRINT("\n\t IPv4 interface address: %s", GET_IPADDR_STRING(tptr));
|
||||
tptr += sizeof(nd_ipv4);
|
||||
tlen -= sizeof(nd_ipv4);
|
||||
@ -3274,14 +3272,12 @@ isis_print(netdissect_options *ndo,
|
||||
|
||||
if (tlen < sizeof(nd_ipv4))
|
||||
break;
|
||||
ND_TCHECK_LEN(tptr, sizeof(nd_ipv4));
|
||||
ND_PRINT("\n\t IPv4 interface address: %s", GET_IPADDR_STRING(tptr));
|
||||
tptr+=sizeof(nd_ipv4);
|
||||
tlen-=sizeof(nd_ipv4);
|
||||
|
||||
if (tlen < sizeof(nd_ipv4))
|
||||
break;
|
||||
ND_TCHECK_LEN(tptr, sizeof(nd_ipv4));
|
||||
ND_PRINT("\n\t IPv4 neighbor address: %s", GET_IPADDR_STRING(tptr));
|
||||
tptr+=sizeof(nd_ipv4);
|
||||
tlen-=sizeof(nd_ipv4);
|
||||
|
@ -309,7 +309,6 @@ ldp_tlv_print(netdissect_options *ndo,
|
||||
switch (af) {
|
||||
case AFNUM_INET:
|
||||
while(tlv_tlen >= sizeof(nd_ipv4)) {
|
||||
ND_TCHECK_LEN(tptr, sizeof(nd_ipv4));
|
||||
ND_PRINT(" %s", GET_IPADDR_STRING(tptr));
|
||||
tlv_tlen-=sizeof(nd_ipv4);
|
||||
tptr+=sizeof(nd_ipv4);
|
||||
|
@ -294,10 +294,7 @@ olsr_print_neighbor(netdissect_options *ndo,
|
||||
neighbor = 1;
|
||||
|
||||
while (hello_len >= sizeof(nd_ipv4)) {
|
||||
|
||||
ND_TCHECK_LEN(msg_data, sizeof(nd_ipv4));
|
||||
/* print 4 neighbors per line */
|
||||
|
||||
ND_PRINT("%s%s", GET_IPADDR_STRING(msg_data),
|
||||
neighbor % 4 == 0 ? "\n\t\t" : " ");
|
||||
|
||||
@ -305,8 +302,6 @@ olsr_print_neighbor(netdissect_options *ndo,
|
||||
hello_len -= sizeof(nd_ipv4);
|
||||
}
|
||||
return (0);
|
||||
trunc:
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -189,7 +189,6 @@ pimv1_join_prune_print(netdissect_options *ndo,
|
||||
|
||||
if (len < sizeof(nd_ipv4))
|
||||
goto trunc;
|
||||
ND_TCHECK_LEN(bp, sizeof(nd_ipv4));
|
||||
if (ndo->ndo_vflag > 1)
|
||||
ND_PRINT("\n");
|
||||
ND_PRINT(" Upstream Nbr: %s", GET_IPADDR_STRING(bp));
|
||||
@ -218,13 +217,11 @@ pimv1_join_prune_print(netdissect_options *ndo,
|
||||
*/
|
||||
if (len < 4)
|
||||
goto trunc;
|
||||
ND_TCHECK_LEN(bp, sizeof(nd_ipv4));
|
||||
ND_PRINT("\n\tGroup: %s", GET_IPADDR_STRING(bp));
|
||||
bp += 4;
|
||||
len -= 4;
|
||||
if (len < 4)
|
||||
goto trunc;
|
||||
ND_TCHECK_LEN(bp, sizeof(nd_ipv4));
|
||||
if (GET_BE_U_4(bp) != 0xffffffff)
|
||||
ND_PRINT("/%s", GET_IPADDR_STRING(bp));
|
||||
bp += 4;
|
||||
@ -303,7 +300,6 @@ pimv1_print(netdissect_options *ndo,
|
||||
GET_IPADDR_STRING(bp + 24));
|
||||
break;
|
||||
case PIMV1_TYPE_REGISTER_STOP:
|
||||
ND_TCHECK_LEN(bp + 12, sizeof(nd_ipv4));
|
||||
ND_PRINT(" for %s > %s", GET_IPADDR_STRING(bp + 8),
|
||||
GET_IPADDR_STRING(bp + 12));
|
||||
break;
|
||||
@ -318,7 +314,6 @@ pimv1_print(netdissect_options *ndo,
|
||||
}
|
||||
break;
|
||||
case PIMV1_TYPE_ASSERT:
|
||||
ND_TCHECK_LEN(bp + 16, sizeof(nd_ipv4));
|
||||
ND_PRINT(" for %s > %s", GET_IPADDR_STRING(bp + 16),
|
||||
GET_IPADDR_STRING(bp + 8));
|
||||
if (GET_BE_U_4(bp + 12) != 0xffffffff)
|
||||
|
Loading…
Reference in New Issue
Block a user