Use more ND_TCHECK_n()/ND_TTEST_n() macros

This commit is contained in:
Francois-Xavier Le Bail 2017-11-24 22:48:55 +01:00
parent c511f4c3be
commit 39c8c55aa9
56 changed files with 469 additions and 467 deletions

View File

@ -1019,7 +1019,7 @@ parse_elements(netdissect_options *ndo,
while (length != 0) {
/* Make sure we at least have the element ID and length. */
if (!ND_TTEST2(*(p + offset), 2))
if (!ND_TTEST_2(p + offset))
return 0;
if (length < 2)
return 0;
@ -1447,7 +1447,7 @@ handle_auth(netdissect_options *ndo,
memset(&pbody, 0, sizeof(pbody));
if (!ND_TTEST2(*p, 6))
if (!ND_TTEST_6(p))
return 0;
if (length < 6)
return 0;
@ -1580,7 +1580,7 @@ static int
handle_action(netdissect_options *ndo,
const uint8_t *src, const u_char *p, u_int length)
{
if (!ND_TTEST2(*p, 2))
if (!ND_TTEST_2(p))
return 0;
if (length < 2)
return 0;

View File

@ -106,7 +106,7 @@ ahcp_time_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
if (cp + 4 != ep)
goto invalid;
ND_TCHECK2(*cp, 4);
ND_TCHECK_4(cp);
t = EXTRACT_BE_U_4(cp);
if (NULL == (tm = gmtime(&t)))
ND_PRINT((ndo, ": gmtime() error"));
@ -130,7 +130,7 @@ ahcp_seconds_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
{
if (cp + 4 != ep)
goto invalid;
ND_TCHECK2(*cp, 4);
ND_TCHECK_4(cp);
ND_PRINT((ndo, ": %us", EXTRACT_BE_U_4(cp)));
return 0;
@ -151,7 +151,7 @@ ahcp_ipv6_addresses_print(netdissect_options *ndo, const u_char *cp, const u_cha
while (cp < ep) {
if (cp + 16 > ep)
goto invalid;
ND_TCHECK2(*cp, 16);
ND_TCHECK_16(cp);
ND_PRINT((ndo, "%s%s", sep, ip6addr_string(ndo, cp)));
cp += 16;
sep = ", ";
@ -175,7 +175,7 @@ ahcp_ipv4_addresses_print(netdissect_options *ndo, const u_char *cp, const u_cha
while (cp < ep) {
if (cp + 4 > ep)
goto invalid;
ND_TCHECK2(*cp, 4);
ND_TCHECK_4(cp);
ND_PRINT((ndo, "%s%s", sep, ipaddr_string(ndo, cp)));
cp += 4;
sep = ", ";
@ -223,7 +223,7 @@ ahcp_ipv4_prefixes_print(netdissect_options *ndo, const u_char *cp, const u_char
while (cp < ep) {
if (cp + 5 > ep)
goto invalid;
ND_TCHECK2(*cp, 5);
ND_TCHECK_5(cp);
ND_PRINT((ndo, "%s%s/%u", sep, ipaddr_string(ndo, cp), *(cp + 4)));
cp += 5;
sep = ", ";
@ -265,7 +265,7 @@ ahcp1_options_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
while (cp < ep) {
/* Option no */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
option_no = *cp;
cp += 1;
ND_PRINT((ndo, "\n\t %s", tok2str(ahcp1_opt_str, "Unknown-%u", option_no)));
@ -274,7 +274,7 @@ ahcp1_options_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
/* Length */
if (cp + 1 > ep)
goto invalid;
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
option_len = *cp;
cp += 1;
if (cp + option_len > ep)
@ -308,15 +308,15 @@ ahcp1_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
if (cp + AHCP1_BODY_MIN_LEN > ep)
goto invalid;
/* Type */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
type = *cp;
cp += 1;
/* MBZ */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
mbz = *cp;
cp += 1;
/* Length */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
body_len = EXTRACT_BE_U_2(cp);
cp += 2;
@ -354,12 +354,12 @@ ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len)
if (len < 2)
goto invalid;
/* Magic */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
if (*cp != AHCP_MAGIC_NUMBER)
goto invalid;
cp += 1;
/* Version */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
version = *cp;
cp += 1;
switch (version) {
@ -372,23 +372,23 @@ ahcp_print(netdissect_options *ndo, const u_char *cp, const u_int len)
cp += AHCP1_HEADER_FIX_LEN - 2;
} else {
/* Hopcount */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, "\n\tHopcount %u", *cp));
cp += 1;
/* Original Hopcount */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, ", Original Hopcount %u", *cp));
cp += 1;
/* Nonce */
ND_TCHECK2(*cp, 4);
ND_TCHECK_4(cp);
ND_PRINT((ndo, ", Nonce 0x%08x", EXTRACT_BE_U_4(cp)));
cp += 4;
/* Source Id */
ND_TCHECK2(*cp, 8);
ND_TCHECK_8(cp);
ND_PRINT((ndo, ", Source Id %s", linkaddr_string(ndo, cp, 0, 8)));
cp += 8;
/* Destination Id */
ND_TCHECK2(*cp, 8);
ND_TCHECK_8(cp);
ND_PRINT((ndo, ", Destination Id %s", linkaddr_string(ndo, cp, 0, 8)));
cp += 8;
}

View File

@ -148,47 +148,47 @@ aoev1_issue_print(netdissect_options *ndo,
if (len < AOEV1_ISSUE_ARG_LEN)
goto invalid;
/* AFlags */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, "\n\tAFlags: [%s]", bittok2str(aoev1_aflag_str, "none", EXTRACT_U_1(cp))));
cp += 1;
/* Err/Feature */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, ", Err/Feature: %u", *cp));
cp += 1;
/* Sector Count (not correlated with the length) */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, ", Sector Count: %u", *cp));
cp += 1;
/* Cmd/Status */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, ", Cmd/Status: %u", *cp));
cp += 1;
/* lba0 */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, "\n\tlba0: %u", *cp));
cp += 1;
/* lba1 */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, ", lba1: %u", *cp));
cp += 1;
/* lba2 */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, ", lba2: %u", *cp));
cp += 1;
/* lba3 */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, ", lba3: %u", *cp));
cp += 1;
/* lba4 */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, ", lba4: %u", *cp));
cp += 1;
/* lba5 */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, ", lba5: %u", *cp));
cp += 1;
/* Reserved */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
cp += 2;
/* Data */
if (len > AOEV1_ISSUE_ARG_LEN)
@ -213,24 +213,24 @@ aoev1_query_print(netdissect_options *ndo,
if (len < AOEV1_QUERY_ARG_LEN)
goto invalid;
/* Buffer Count */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
ND_PRINT((ndo, "\n\tBuffer Count: %u", EXTRACT_BE_U_2(cp)));
cp += 2;
/* Firmware Version */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
ND_PRINT((ndo, ", Firmware Version: %u", EXTRACT_BE_U_2(cp)));
cp += 2;
/* Sector Count */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, ", Sector Count: %u", *cp));
cp += 1;
/* AoE/CCmd */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, ", AoE: %u, CCmd: %s", (EXTRACT_U_1(cp) & 0xF0) >> 4,
tok2str(aoev1_ccmd_str, "Unknown (0x02x)", EXTRACT_U_1(cp) & 0x0F)));
cp += 1;
/* Config String Length */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
cslen = EXTRACT_BE_U_2(cp);
cp += 2;
if (cslen > AOEV1_MAX_CONFSTR_LEN || AOEV1_QUERY_ARG_LEN + cslen > len)
@ -262,18 +262,18 @@ aoev1_mac_print(netdissect_options *ndo,
if (len < AOEV1_MAC_ARG_LEN)
goto invalid;
/* Reserved */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
cp += 1;
/* MCmd */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, "\n\tMCmd: %s", tok2str(aoev1_mcmd_str, "Unknown (0x%02x)", EXTRACT_U_1(cp))));
cp += 1;
/* MError */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, ", MError: %s", tok2str(aoev1_merror_str, "Unknown (0x%02x)", EXTRACT_U_1(cp))));
cp += 1;
/* Dir Count */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
dircount = *cp;
cp += 1;
ND_PRINT((ndo, ", Dir Count: %u", dircount));
@ -282,10 +282,10 @@ aoev1_mac_print(netdissect_options *ndo,
/* directives */
for (i = 0; i < dircount; i++) {
/* Reserved */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
cp += 1;
/* DCmd */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, "\n\t DCmd: %s", tok2str(aoev1_dcmd_str, "Unknown (0x%02x)", EXTRACT_U_1(cp))));
cp += 1;
/* Ethernet Address */
@ -313,11 +313,11 @@ aoev1_reserve_print(netdissect_options *ndo,
if (len < AOEV1_RESERVE_ARG_LEN || (len - AOEV1_RESERVE_ARG_LEN) % ETHER_ADDR_LEN)
goto invalid;
/* RCmd */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, "\n\tRCmd: %s", tok2str(aoev1_rcmd_str, "Unknown (0x%02x)", EXTRACT_U_1(cp))));
cp += 1;
/* NMacs (correlated with the length) */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
nmacs = *cp;
cp += 1;
ND_PRINT((ndo, ", NMacs: %u", nmacs));
@ -356,25 +356,25 @@ aoev1_print(netdissect_options *ndo,
if (! ndo->ndo_vflag)
return;
/* Error */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
if (flags & AOEV1_FLAG_E)
ND_PRINT((ndo, "\n\tError: %s", tok2str(aoev1_errcode_str, "Invalid (%u)", EXTRACT_U_1(cp))));
cp += 1;
/* Major */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
ND_PRINT((ndo, "\n\tMajor: 0x%04x", EXTRACT_BE_U_2(cp)));
cp += 2;
/* Minor */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ND_PRINT((ndo, ", Minor: 0x%02x", *cp));
cp += 1;
/* Command */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
command = *cp;
cp += 1;
ND_PRINT((ndo, ", Command: %s", tok2str(cmdcode_str, "Unknown (0x%02x)", command)));
/* Tag */
ND_TCHECK2(*cp, 4);
ND_TCHECK_4(cp);
ND_PRINT((ndo, ", Tag: 0x%08x", EXTRACT_BE_U_4(cp)));
cp += 4;
/* Arg */
@ -408,7 +408,7 @@ aoe_print(netdissect_options *ndo,
if (len < 1)
goto invalid;
/* Ver/Flags */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
ver = (EXTRACT_U_1(cp) & 0xF0) >> 4;
/* Don't advance cp yet: low order 4 bits are version-specific. */
ND_PRINT((ndo, ", Ver %u", ver));

View File

@ -538,7 +538,7 @@ oam_print (netdissect_options *ndo,
}
/* crc10 checksum verification */
ND_TCHECK2(*(p + OAM_CELLTYPE_FUNCTYPE_LEN + OAM_FUNCTION_SPECIFIC_LEN), 2);
ND_TCHECK_2(p + OAM_CELLTYPE_FUNCTYPE_LEN + OAM_FUNCTION_SPECIFIC_LEN);
cksum = EXTRACT_BE_U_2(p + OAM_CELLTYPE_FUNCTYPE_LEN + OAM_FUNCTION_SPECIFIC_LEN)
& OAM_CRC10_MASK;
cksum_shouldbe = verify_crc10_cksum(0, p, OAM_PAYLOAD_LEN);

View File

@ -51,7 +51,7 @@ babel_print(netdissect_options *ndo,
{
ND_PRINT((ndo, "babel"));
ND_TCHECK2(*cp, 4);
ND_TCHECK_4(cp);
if(cp[0] != 42) {
ND_PRINT((ndo, " invalid header"));
@ -350,7 +350,7 @@ babel_print_v2(netdissect_options *ndo,
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF, 0, 0, 0, 0 };
u_char v6_prefix[16] = {0};
ND_TCHECK2(*cp, 4);
ND_TCHECK_4(cp);
if (length < 4)
goto invalid;
bodylen = EXTRACT_BE_U_2(cp + 2);
@ -364,14 +364,14 @@ babel_print_v2(netdissect_options *ndo,
message = cp + 4 + i;
ND_TCHECK2(*message, 1);
ND_TCHECK_1(message);
if((type = message[0]) == MESSAGE_PAD1) {
ND_PRINT((ndo, ndo->ndo_vflag ? "\n\tPad 1" : " pad1"));
i += 1;
continue;
}
ND_TCHECK2(*message, 2);
ND_TCHECK_2(message);
ICHECK(i, 2);
len = message[1];

View File

@ -242,7 +242,7 @@ auth_print(netdissect_options *ndo, register const u_char *pptr)
break;
}
pptr += 2;
ND_TCHECK2(*pptr, 4);
ND_TCHECK_4(pptr);
ND_PRINT((ndo, ", Sequence Number: 0x%08x", EXTRACT_BE_U_4(pptr)));
pptr += 4;
ND_TCHECK2(*pptr, AUTH_MD5_HASH_LEN);
@ -273,7 +273,7 @@ auth_print(netdissect_options *ndo, register const u_char *pptr)
break;
}
pptr += 2;
ND_TCHECK2(*pptr, 4);
ND_TCHECK_4(pptr);
ND_PRINT((ndo, ", Sequence Number: 0x%08x", EXTRACT_BE_U_4(pptr)));
pptr += 4;
ND_TCHECK2(*pptr, AUTH_SHA1_HASH_LEN);

View File

@ -572,7 +572,7 @@ decode_labeled_prefix4(netdissect_options *ndo,
u_int plen, plenbytes;
/* prefix length and label = 4 bytes */
ND_TCHECK2(pptr[0], 4);
ND_TCHECK_4(pptr);
ITEMCHECK(4);
plen = pptr[0]; /* get prefix length */
@ -881,7 +881,7 @@ decode_mdt_vpn_nlri(netdissect_options *ndo,
pptr++;
/* RD */
ND_TCHECK2(pptr[0], 8);
ND_TCHECK_8(pptr);
rd = pptr;
pptr+=8;
@ -929,7 +929,7 @@ decode_multicast_vpn(netdissect_options *ndo,
uint8_t route_type, route_length, addr_length, sg_length;
u_int offset;
ND_TCHECK2(pptr[0], 2);
ND_TCHECK_2(pptr);
route_type = EXTRACT_U_1(pptr);
pptr++;
route_length = EXTRACT_U_1(pptr);
@ -1076,7 +1076,7 @@ decode_labeled_vpn_l2(netdissect_options *ndo,
while (tlen>0) {
if (tlen < 3)
return -1;
ND_TCHECK2(pptr[0], 3);
ND_TCHECK_3(pptr);
tlv_type=EXTRACT_U_1(pptr);
pptr++;
tlv_len=EXTRACT_BE_U_2(pptr);
@ -1167,7 +1167,7 @@ decode_labeled_prefix6(netdissect_options *ndo,
u_int plen, plenbytes;
/* prefix length and label = 4 bytes */
ND_TCHECK2(pptr[0], 4);
ND_TCHECK_4(pptr);
ITEMCHECK(4);
plen = pptr[0]; /* get prefix length */
@ -1450,7 +1450,7 @@ bgp_attr_print(netdissect_options *ndo,
if (len != 4)
ND_PRINT((ndo, "invalid len"));
else {
ND_TCHECK2(tptr[0], 4);
ND_TCHECK_4(tptr);
ND_PRINT((ndo, "%s", ipaddr_string(ndo, tptr)));
}
break;
@ -1493,7 +1493,7 @@ bgp_attr_print(netdissect_options *ndo,
ND_PRINT((ndo, "invalid len"));
break;
}
ND_TCHECK2(tptr[0], 8);
ND_TCHECK_8(tptr);
ND_PRINT((ndo, " AS #%s, origin %s",
as_printf(ndo, astostr, sizeof(astostr), EXTRACT_BE_U_4(tptr)),
ipaddr_string(ndo, tptr + 4)));
@ -1533,7 +1533,7 @@ bgp_attr_print(netdissect_options *ndo,
ND_PRINT((ndo, "invalid len"));
break;
}
ND_TCHECK2(tptr[0], 4);
ND_TCHECK_4(tptr);
ND_PRINT((ndo, "%s",ipaddr_string(ndo, tptr)));
break;
case BGPTYPE_CLUSTER_LIST:
@ -1542,7 +1542,7 @@ bgp_attr_print(netdissect_options *ndo,
break;
}
while (tlen>0) {
ND_TCHECK2(tptr[0], 4);
ND_TCHECK_4(tptr);
ND_PRINT((ndo, "%s%s",
ipaddr_string(ndo, tptr),
(tlen>4) ? ", " : ""));
@ -1551,7 +1551,7 @@ bgp_attr_print(netdissect_options *ndo,
}
break;
case BGPTYPE_MP_REACH_NLRI:
ND_TCHECK2(tptr[0], 3);
ND_TCHECK_3(tptr);
af = EXTRACT_BE_U_2(tptr);
safi = EXTRACT_U_1(tptr + 2);
@ -2075,7 +2075,7 @@ bgp_attr_print(netdissect_options *ndo,
extd_comm,
bittok2str(bgp_extd_comm_flag_values, "none", extd_comm)));
ND_TCHECK2(*(tptr+2), 6);
ND_TCHECK_6(tptr + 2);
switch(extd_comm) {
case BGP_EXT_COM_RT_0:
case BGP_EXT_COM_RO_0:
@ -2134,7 +2134,7 @@ bgp_attr_print(netdissect_options *ndo,
ND_PRINT((ndo, ": AS %u", EXTRACT_BE_U_2(tptr + 2)));
break;
default:
ND_TCHECK2(*tptr,8);
ND_TCHECK_8(tptr);
print_unknown_data(ndo, tptr, "\n\t ", 8);
break;
}
@ -2147,7 +2147,7 @@ bgp_attr_print(netdissect_options *ndo,
{
uint8_t tunnel_type, flags;
ND_TCHECK2(tptr[0], 5);
ND_TCHECK_5(tptr);
flags = EXTRACT_U_1(tptr);
tunnel_type = EXTRACT_U_1(tptr + 1);
tlen = len;
@ -2164,32 +2164,32 @@ bgp_attr_print(netdissect_options *ndo,
switch (tunnel_type) {
case BGP_PMSI_TUNNEL_PIM_SM: /* fall through */
case BGP_PMSI_TUNNEL_PIM_BIDIR:
ND_TCHECK2(tptr[0], 8);
ND_TCHECK_8(tptr);
ND_PRINT((ndo, "\n\t Sender %s, P-Group %s",
ipaddr_string(ndo, tptr),
ipaddr_string(ndo, tptr+4)));
break;
case BGP_PMSI_TUNNEL_PIM_SSM:
ND_TCHECK2(tptr[0], 8);
ND_TCHECK_8(tptr);
ND_PRINT((ndo, "\n\t Root-Node %s, P-Group %s",
ipaddr_string(ndo, tptr),
ipaddr_string(ndo, tptr+4)));
break;
case BGP_PMSI_TUNNEL_INGRESS:
ND_TCHECK2(tptr[0], 4);
ND_TCHECK_4(tptr);
ND_PRINT((ndo, "\n\t Tunnel-Endpoint %s",
ipaddr_string(ndo, tptr)));
break;
case BGP_PMSI_TUNNEL_LDP_P2MP: /* fall through */
case BGP_PMSI_TUNNEL_LDP_MP2MP:
ND_TCHECK2(tptr[0], 8);
ND_TCHECK_8(tptr);
ND_PRINT((ndo, "\n\t Root-Node %s, LSP-ID 0x%08x",
ipaddr_string(ndo, tptr),
EXTRACT_BE_U_4(tptr + 4)));
break;
case BGP_PMSI_TUNNEL_RSVP_P2MP:
ND_TCHECK2(tptr[0], 8);
ND_TCHECK_8(tptr);
ND_PRINT((ndo, "\n\t Extended-Tunnel-ID %s, P2MP-ID 0x%08x",
ipaddr_string(ndo, tptr),
EXTRACT_BE_U_4(tptr + 4)));
@ -2210,7 +2210,7 @@ bgp_attr_print(netdissect_options *ndo,
while (tlen >= 3) {
ND_TCHECK2(tptr[0], 3);
ND_TCHECK_3(tptr);
type = EXTRACT_U_1(tptr);
length = EXTRACT_BE_U_2(tptr + 1);
@ -2262,7 +2262,7 @@ bgp_attr_print(netdissect_options *ndo,
while (len) {
u_int aflags, alenlen, alen;
ND_TCHECK2(tptr[0], 2);
ND_TCHECK_2(tptr);
if (len < 2)
goto trunc;
aflags = EXTRACT_U_1(tptr);
@ -2555,7 +2555,7 @@ bgp_update_print(netdissect_options *ndo,
while (len) {
int aflags, atype, alenlen, alen;
ND_TCHECK2(p[0], 2);
ND_TCHECK_2(p);
if (len < 2)
goto trunc;
if (length < 2)
@ -2700,7 +2700,7 @@ bgp_notification_print(netdissect_options *ndo,
*/
if(bgpn.bgpn_minor == BGP_NOTIFY_MINOR_CEASE_MAXPRFX && length >= BGP_NOTIFICATION_SIZE + 7) {
tptr = dat + BGP_NOTIFICATION_SIZE;
ND_TCHECK2(*tptr, 7);
ND_TCHECK_7(tptr);
ND_PRINT((ndo, ", AFI %s (%u), SAFI %s (%u), Max Prefixes: %u",
tok2str(af_values, "Unknown",
EXTRACT_BE_U_2(tptr)),
@ -2854,7 +2854,7 @@ bgp_print(netdissect_options *ndo,
p = dat;
start = p;
while (p < ep) {
if (!ND_TTEST2(p[0], 1))
if (!ND_TTEST_1(p))
break;
if (p[0] != 0xff) {
p++;

View File

@ -24,6 +24,7 @@
#include <netdissect-stdinc.h>
#include "netdissect.h"
#include "extract.h"
#include "addrtoname.h"
/*
@ -42,7 +43,7 @@ calm_fast_print(netdissect_options *ndo, const u_char *bp, u_int length, const s
int srcNwref;
int dstNwref;
ND_TCHECK2(*bp, 2);
ND_TCHECK_2(bp);
if (length < 2)
goto trunc;
srcNwref = bp[0];

View File

@ -285,21 +285,21 @@ cdp_print_addr(netdissect_options *ndo,
0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x86, 0xdd
};
ND_TCHECK2(*p, 4);
ND_TCHECK_4(p);
if (p + 4 > endp)
goto trunc;
num = EXTRACT_BE_U_4(p);
p += 4;
while (p < endp && num >= 0) {
ND_TCHECK2(*p, 2);
ND_TCHECK_2(p);
if (p + 2 > endp)
goto trunc;
pt = p[0]; /* type of "protocol" field */
pl = p[1]; /* length of "protocol" field */
p += 2;
ND_TCHECK2(p[pl], 2);
ND_TCHECK_2(p + pl);
if (p + pl + 2 > endp)
goto trunc;
al = EXTRACT_BE_U_2(p + pl); /* address length */
@ -312,7 +312,7 @@ cdp_print_addr(netdissect_options *ndo,
*/
p += 3;
ND_TCHECK2(*p, 4);
ND_TCHECK_4(p);
if (p + 4 > endp)
goto trunc;
ND_PRINT((ndo, "IPv4 (%u) %s", num, ipaddr_string(ndo, p)));
@ -346,7 +346,7 @@ cdp_print_addr(netdissect_options *ndo,
ND_PRINT((ndo, " %02x", EXTRACT_U_1(p)));
p++;
}
ND_TCHECK2(*p, 2);
ND_TCHECK_2(p);
if (p + 2 > endp)
goto trunc;
ND_PRINT((ndo, ", al=%d, a=", al));

View File

@ -177,7 +177,7 @@ chdlc_slarp_print(netdissect_options *ndo, const u_char *cp, u_int length)
if (length >= SLARP_MAX_LEN) { /* uptime-stamp is optional */
cp += SLARP_MIN_LEN;
ND_TCHECK2(*cp, 4);
ND_TCHECK_4(cp);
sec = EXTRACT_BE_U_4(cp) / 1000;
min = sec / 60; sec -= min * 60;
hrs = min / 60; min -= hrs * 60;

View File

@ -446,7 +446,7 @@ cnfp_print(netdissect_options *ndo, const u_char *cp)
/*
* First 2 bytes are the version number.
*/
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
ver = EXTRACT_BE_U_2(cp);
switch (ver) {

View File

@ -245,10 +245,10 @@ static void dccp_print_ack_no(netdissect_options *ndo, const u_char *bp)
uint64_t ackno;
if (DCCPH_X(dh) != 0) {
ND_TCHECK2(*ackp, 8);
ND_TCHECK_8(ackp);
ackno = EXTRACT_BE_U_6(ackp + 2);
} else {
ND_TCHECK2(*ackp, 4);
ND_TCHECK_4(ackp);
ackno = EXTRACT_BE_U_3(ackp + 1);
}

View File

@ -338,7 +338,7 @@ ns_qprint(netdissect_options *ndo,
cp = ns_nskip(ndo, cp);
if (cp == NULL || !ND_TTEST2(*cp, 4))
if (cp == NULL || !ND_TTEST_4(cp))
return(NULL);
/* print the qtype */
@ -467,7 +467,7 @@ ns_rprint(netdissect_options *ndo,
break;
case T_MX:
ND_PRINT((ndo, " "));
if (!ND_TTEST2(*cp, 2))
if (!ND_TTEST_2(cp))
return(NULL);
if (ns_nprint(ndo, cp + 2, bp) == NULL)
return(NULL);
@ -486,7 +486,7 @@ ns_rprint(netdissect_options *ndo,
case T_SRV:
ND_PRINT((ndo, " "));
if (!ND_TTEST2(*cp, 6))
if (!ND_TTEST_6(cp))
return(NULL);
if (ns_nprint(ndo, cp + 6, bp) == NULL)
return(NULL);

View File

@ -71,7 +71,7 @@ dtp_print (netdissect_options *ndo, const u_char *pptr, u_int length)
while (tptr < (pptr+length)) {
ND_TCHECK2(*tptr, 4);
ND_TCHECK_4(tptr);
type = EXTRACT_BE_U_2(tptr);
len = EXTRACT_BE_U_2(tptr + 2);
/* XXX: should not be but sometimes it is, see the test captures */

View File

@ -122,7 +122,7 @@ dvmrp_print(netdissect_options *ndo,
* extract version from IGMP group address field
*/
bp -= 4;
ND_TCHECK2(bp[0], 4);
ND_TCHECK_4(bp);
major_version = EXTRACT_U_1(bp + 3);
minor_version = EXTRACT_U_1(bp + 2);
bp += 4;
@ -174,7 +174,7 @@ print_report(netdissect_options *ndo,
ND_PRINT((ndo, " [|]"));
return (0);
}
ND_TCHECK2(bp[0], 3);
ND_TCHECK_3(bp);
mask = (uint32_t)0xff << 24 | bp[0] << 16 | bp[1] << 8 | bp[2];
width = 1;
if (bp[0])
@ -227,7 +227,7 @@ print_probe(netdissect_options *ndo,
{
register uint32_t genid;
ND_TCHECK2(bp[0], 4);
ND_TCHECK_4(bp);
if ((len < 4) || ((bp + 4) > ep)) {
/* { (ctags) */
ND_PRINT((ndo, " [|}"));
@ -242,7 +242,7 @@ print_probe(netdissect_options *ndo,
return (0);
while ((len > 0) && (bp < ep)) {
ND_TCHECK2(bp[0], 4);
ND_TCHECK_4(bp);
ND_PRINT((ndo, "\n\tneighbor %s", ipaddr_string(ndo, bp)));
bp += 4; len -= 4;
}
@ -262,7 +262,7 @@ print_neighbors(netdissect_options *ndo,
register int ncount;
while (len > 0 && bp < ep) {
ND_TCHECK2(bp[0], 7);
ND_TCHECK_7(bp);
laddr = bp;
bp += 4;
metric = EXTRACT_U_1(bp);
@ -273,7 +273,7 @@ print_neighbors(netdissect_options *ndo,
bp++;
len -= 7;
while (--ncount >= 0) {
ND_TCHECK2(bp[0], 4);
ND_TCHECK_4(bp);
ND_PRINT((ndo, " [%s ->", ipaddr_string(ndo, laddr)));
ND_PRINT((ndo, " %s, (%d/%d)]",
ipaddr_string(ndo, bp), metric, thresh));
@ -299,7 +299,7 @@ print_neighbors2(netdissect_options *ndo,
ND_PRINT((ndo, " (v %u.%u):", major_version, minor_version));
while (len > 0 && bp < ep) {
ND_TCHECK2(bp[0], 8);
ND_TCHECK_8(bp);
laddr = bp;
bp += 4;
metric = EXTRACT_U_1(bp);
@ -357,7 +357,7 @@ static int
print_graft(netdissect_options *ndo,
register const u_char *bp)
{
ND_TCHECK2(bp[0], 8);
ND_TCHECK_8(bp);
ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4)));
return (0);
trunc:
@ -368,7 +368,7 @@ static int
print_graft_ack(netdissect_options *ndo,
register const u_char *bp)
{
ND_TCHECK2(bp[0], 8);
ND_TCHECK_8(bp);
ND_PRINT((ndo, " src %s grp %s", ipaddr_string(ndo, bp), ipaddr_string(ndo, bp + 4)));
return (0);
trunc:

View File

@ -843,7 +843,7 @@ pdatacnt_print(netdissect_options *ndo,
ND_PRINT((ndo, "%sTABLE APPEND\n", ib));
}
for (i = 0; i < IDcnt; i++) {
ND_TCHECK2(*pptr, 4);
ND_TCHECK_4(pptr);
if (len < 4)
goto trunc;
id = EXTRACT_BE_U_4(pptr);
@ -1228,7 +1228,7 @@ asttlv_print(netdissect_options *ndo,
ND_PRINT((ndo, "illegal ASTresult-TLV: %d bytes!\n", dlen));
return -1;
}
ND_TCHECK2(*pptr, 4);
ND_TCHECK_4(pptr);
rescode = EXTRACT_BE_U_4(pptr);
if (rescode > ASTMCD) {
ND_PRINT((ndo, "illegal ASTresult result code: %d!\n", rescode));
@ -1286,7 +1286,7 @@ asrtlv_print(netdissect_options *ndo,
ND_PRINT((ndo, "illegal ASRresult-TLV: %d bytes!\n", dlen));
return -1;
}
ND_TCHECK2(*pptr, 4);
ND_TCHECK_4(pptr);
rescode = EXTRACT_BE_U_4(pptr);
if (rescode > ASRMCD) {
@ -1706,7 +1706,7 @@ forces_print(netdissect_options *ndo,
goto error;
}
ND_TCHECK2(*(pptr + 20), 4);
ND_TCHECK_4(pptr + 20);
flg_raw = EXTRACT_BE_U_4(pptr + 20);
if (ndo->ndo_vflag >= 1) {
ND_PRINT((ndo, "\n\tForCES Version %d len %uB flags 0x%08x ",

View File

@ -222,7 +222,7 @@ fr_if_print(netdissect_options *ndo,
register u_int length = h->len;
register u_int caplen = h->caplen;
ND_TCHECK2(*p, 4); /* minimum frame header length */
ND_TCHECK_4(p); /* minimum frame header length */
if ((length = fr_print(ndo, p, length)) == 0)
return (0);
@ -378,7 +378,7 @@ mfr_if_print(netdissect_options *ndo,
register u_int length = h->len;
register u_int caplen = h->caplen;
ND_TCHECK2(*p, 2); /* minimum frame header length */
ND_TCHECK_2(p); /* minimum frame header length */
if ((length = mfr_print(ndo, p, length)) == 0)
return (0);
@ -456,7 +456,7 @@ mfr_print(netdissect_options *ndo,
* +----+----+----+----+----+----+----+----+
*/
ND_TCHECK2(*p, 4); /* minimum frame header length */
ND_TCHECK_4(p); /* minimum frame header length */
if ((EXTRACT_U_1(p) & MFR_BEC_MASK) == MFR_CTRL_FRAME && EXTRACT_U_1(p + 1) == 0) {
ND_PRINT((ndo, "FRF.16 Control, Flags [%s], %s, length %u",
@ -602,7 +602,7 @@ frf15_print(netdissect_options *ndo,
if (length < 2)
goto trunc;
ND_TCHECK2(*p, 2);
ND_TCHECK_2(p);
flags = EXTRACT_U_1(p)&MFR_BEC_MASK;
sequence_num = (EXTRACT_U_1(p)&0x1e)<<7 | EXTRACT_U_1(p + 1);

View File

@ -155,7 +155,7 @@ geneve_print(netdissect_options *ndo, const u_char *bp, u_int len)
ND_PRINT((ndo, "Geneve"));
ND_TCHECK2(*bp, 8);
ND_TCHECK_8(bp);
ver_opt = EXTRACT_U_1(bp);
bp += 1;

View File

@ -90,7 +90,7 @@ print_long_pos_vector(netdissect_options *ndo,
return (-1);
ND_PRINT((ndo, "GN_ADDR:%s ", linkaddr_string (ndo, bp, 0, GEONET_ADDR_LEN)));
if (!ND_TTEST2(*(bp+12), 8))
if (!ND_TTEST_8(bp + 12))
return (-1);
lat = EXTRACT_BE_U_4(bp + 12);
ND_PRINT((ndo, "lat:%d ", lat));
@ -127,7 +127,7 @@ geonet_print(netdissect_options *ndo, const u_char *bp, u_int length,
if (length < 36)
goto invalid;
ND_TCHECK2(*bp, 8);
ND_TCHECK_8(bp);
version = bp[0] >> 4;
next_hdr = bp[0] & 0x0f;
hdr_type = bp[1] >> 4;
@ -242,7 +242,7 @@ geonet_print(netdissect_options *ndo, const u_char *bp, u_int length,
case 2: /* BTP A/B */
if (length < 4)
goto invalid;
ND_TCHECK2(*bp, 4);
ND_TCHECK_4(bp);
print_btp(ndo, bp);
length -= 4;
bp += 4;
@ -254,7 +254,7 @@ geonet_print(netdissect_options *ndo, const u_char *bp, u_int length,
* or was that just not
* reporting genuine errors?
*/
ND_TCHECK2(*bp, 2);
ND_TCHECK_2(bp);
print_btp_body(ndo, bp);
}
break;

View File

@ -89,7 +89,7 @@ gre_print(netdissect_options *ndo, const u_char *bp, u_int length)
{
u_int len = length, vers;
ND_TCHECK2(*bp, 2);
ND_TCHECK_2(bp);
if (len < 2)
goto trunc;
vers = EXTRACT_BE_U_2(bp) & GRE_VERS_MASK;
@ -128,7 +128,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
len -= 2;
bp += 2;
ND_TCHECK2(*bp, 2);
ND_TCHECK_2(bp);
if (len < 2)
goto trunc;
prot = EXTRACT_BE_U_2(bp);
@ -136,7 +136,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
bp += 2;
if ((flags & GRE_CP) | (flags & GRE_RP)) {
ND_TCHECK2(*bp, 2);
ND_TCHECK_2(bp);
if (len < 2)
goto trunc;
if (ndo->ndo_vflag)
@ -144,7 +144,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
bp += 2;
len -= 2;
ND_TCHECK2(*bp, 2);
ND_TCHECK_2(bp);
if (len < 2)
goto trunc;
ND_PRINT((ndo, ", off 0x%x", EXTRACT_BE_U_2(bp)));
@ -153,7 +153,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
}
if (flags & GRE_KP) {
ND_TCHECK2(*bp, 4);
ND_TCHECK_4(bp);
if (len < 4)
goto trunc;
ND_PRINT((ndo, ", key=0x%x", EXTRACT_BE_U_4(bp)));
@ -162,7 +162,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
}
if (flags & GRE_SP) {
ND_TCHECK2(*bp, 4);
ND_TCHECK_4(bp);
if (len < 4)
goto trunc;
ND_PRINT((ndo, ", seq %u", EXTRACT_BE_U_4(bp)));
@ -176,7 +176,7 @@ gre_print_0(netdissect_options *ndo, const u_char *bp, u_int length)
uint8_t sreoff;
uint8_t srelen;
ND_TCHECK2(*bp, 4);
ND_TCHECK_4(bp);
if (len < 4)
goto trunc;
af = EXTRACT_BE_U_2(bp);
@ -256,7 +256,7 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
ND_PRINT((ndo, ", Flags [%s]",
bittok2str(gre_flag_values,"none",flags)));
ND_TCHECK2(*bp, 2);
ND_TCHECK_2(bp);
if (len < 2)
goto trunc;
prot = EXTRACT_BE_U_2(bp);
@ -267,7 +267,7 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
if (flags & GRE_KP) {
uint32_t k;
ND_TCHECK2(*bp, 4);
ND_TCHECK_4(bp);
if (len < 4)
goto trunc;
k = EXTRACT_BE_U_4(bp);
@ -277,7 +277,7 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
}
if (flags & GRE_SP) {
ND_TCHECK2(*bp, 4);
ND_TCHECK_4(bp);
if (len < 4)
goto trunc;
ND_PRINT((ndo, ", seq %u", EXTRACT_BE_U_4(bp)));
@ -286,7 +286,7 @@ gre_print_1(netdissect_options *ndo, const u_char *bp, u_int length)
}
if (flags & GRE_AP) {
ND_TCHECK2(*bp, 4);
ND_TCHECK_4(bp);
if (len < 4)
goto trunc;
ND_PRINT((ndo, ", ack %u", EXTRACT_BE_U_4(bp)));
@ -371,7 +371,7 @@ gre_sre_ip_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
}
while (srelen != 0) {
if (!ND_TTEST2(*bp, 4))
if (!ND_TTEST_4(bp))
return (0);
if (len < 4)
return (0);
@ -407,7 +407,7 @@ gre_sre_asn_print(netdissect_options *ndo, uint8_t sreoff, uint8_t srelen,
}
while (srelen != 0) {
if (!ND_TTEST2(*bp, 2))
if (!ND_TTEST_2(bp))
return (0);
if (len < 2)
return (0);

View File

@ -1505,7 +1505,7 @@ mldv2_query_print(netdissect_options *ndo, const u_char *bp, u_int len)
ND_PRINT((ndo," qqi=%d", qqi));
}
ND_TCHECK2(bp[26], 2);
ND_TCHECK_2(bp + 26);
nsrcs = EXTRACT_BE_U_2(bp + 26);
if (nsrcs > 0) {
if (len < 28 + nsrcs * sizeof(struct in6_addr))

View File

@ -175,7 +175,7 @@ print_igmpv3_report(netdissect_options *ndo,
ND_PRINT((ndo, " [invalid number of groups]"));
return;
}
ND_TCHECK2(bp[group+4], 4);
ND_TCHECK_4(bp + (group + 4));
ND_PRINT((ndo, " [gaddr %s", ipaddr_string(ndo, &bp[group+4])));
ND_PRINT((ndo, " %s", tok2str(igmpv3report2str, " [v3-report-#%d]",
EXTRACT_U_1(bp + group))));
@ -191,7 +191,7 @@ print_igmpv3_report(netdissect_options *ndo,
/* Print the sources */
ND_PRINT((ndo, " {"));
for (j=0; j<nsrcs; j++) {
ND_TCHECK2(bp[group+8+(j<<2)], 4);
ND_TCHECK_4(bp + (group + 8 + (j << 2)));
ND_PRINT((ndo, " %s", ipaddr_string(ndo, &bp[group+8+(j<<2)])));
}
ND_PRINT((ndo, " }"));
@ -249,7 +249,7 @@ print_igmpv3_query(netdissect_options *ndo,
else if (ndo->ndo_vflag > 1) {
ND_PRINT((ndo, " {"));
for (i=0; i<nsrcs; i++) {
ND_TCHECK2(bp[12+(i<<2)], 4);
ND_TCHECK_4(bp + (12 + (i << 2)));
ND_PRINT((ndo, " %s", ipaddr_string(ndo, &bp[12+(i<<2)])));
}
ND_PRINT((ndo, " }"));
@ -295,13 +295,13 @@ igmp_print(netdissect_options *ndo,
}
break;
case 0x12:
ND_TCHECK2(bp[4], 4);
ND_TCHECK_4(bp + 4);
ND_PRINT((ndo, "igmp v1 report %s", ipaddr_string(ndo, &bp[4])));
if (len != 8)
ND_PRINT((ndo, " [len %d]", len));
break;
case 0x16:
ND_TCHECK2(bp[4], 4);
ND_TCHECK_4(bp + 4);
ND_PRINT((ndo, "igmp v2 report %s", ipaddr_string(ndo, &bp[4])));
break;
case 0x22:
@ -309,7 +309,7 @@ igmp_print(netdissect_options *ndo,
print_igmpv3_report(ndo, bp, len);
break;
case 0x17:
ND_TCHECK2(bp[4], 4);
ND_TCHECK_4(bp + 4);
ND_PRINT((ndo, "igmp leave %s", ipaddr_string(ndo, &bp[4])));
break;
case 0x13:

View File

@ -73,7 +73,7 @@ ip_printroute(netdissect_options *ndo,
ND_PRINT((ndo, " [bad ptr %u]", cp[2]));
for (len = 3; len < length; len += 4) {
ND_TCHECK2(cp[len], 4);
ND_TCHECK_4(cp + len);
ND_PRINT((ndo, " %s", ipaddr_string(ndo, &cp[len])));
if (ptr > len)
ND_PRINT((ndo, ","));

View File

@ -76,7 +76,7 @@ ip6_finddst(netdissect_options *ndo, struct in6_addr *dst,
* the header, in units of 8 octets, excluding
* the first 8 octets.
*/
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
advance = (EXTRACT_U_1(cp + 1) + 1) << 3;
nh = *cp;
break;
@ -87,7 +87,7 @@ ip6_finddst(netdissect_options *ndo, struct in6_addr *dst,
* marked as reserved, and the header is always
* the same size.
*/
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
advance = sizeof(struct ip6_frag);
nh = *cp;
break;

View File

@ -2015,7 +2015,7 @@ isis_print_ext_is_reach(netdissect_options *ndo,
if (subtlv_sum_len) {
ND_PRINT((ndo, " (%u)", subtlv_sum_len));
while (subtlv_sum_len>0) {
if (!ND_TTEST2(*tptr,2))
if (!ND_TTEST_2(tptr))
return(0);
subtlv_type=EXTRACT_U_1(tptr);
subtlv_len=EXTRACT_U_1(tptr + 1);
@ -2092,7 +2092,7 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
}
processed++;
} else if (afi == AF_INET6) {
if (!ND_TTEST2(*tptr, 2)) /* fetch status & prefix_len byte */
if (!ND_TTEST_2(tptr)) /* fetch status & prefix_len byte */
return (0);
status_byte=EXTRACT_U_1(tptr);
bit_length=EXTRACT_U_1(tptr + 1);
@ -2153,7 +2153,7 @@ isis_print_extd_ip_reach(netdissect_options *ndo,
ND_PRINT((ndo, " (%u)", sublen)); /* print out subTLV length */
while (sublen>0) {
if (!ND_TTEST2(*tptr,2))
if (!ND_TTEST_2(tptr))
return (0);
subtlvtype=EXTRACT_U_1(tptr);
subtlvlen=EXTRACT_U_1(tptr + 1);
@ -3189,7 +3189,7 @@ osi_print_cksum(netdissect_options *ndo, const uint8_t *pptr,
*/
if (!checksum
|| checksum_offset < 0
|| !ND_TTEST2(*(pptr + checksum_offset), 2)
|| !ND_TTEST_2(pptr + checksum_offset)
|| (u_int)checksum_offset > length
|| !ND_TTEST2(*pptr, length)) {
ND_PRINT((ndo, " (unverified)"));

View File

@ -760,7 +760,7 @@ juniper_pppoe_atm_if_print(netdissect_options *ndo,
p+=l2info.header_len;
ND_TCHECK2(p[0], 2);
ND_TCHECK_2(p);
extracted_ethertype = EXTRACT_BE_U_2(p);
/* this DLT contains nothing but raw PPPoE frames,
* prepended with a type field*/
@ -965,7 +965,7 @@ juniper_atm1_if_print(netdissect_options *ndo,
return l2info.header_len;
}
ND_TCHECK2(p[0], 3);
ND_TCHECK_3(p);
if (EXTRACT_BE_U_3(p) == 0xfefe03 || /* NLPID encaps ? */
EXTRACT_BE_U_3(p) == 0xaaaa03) { /* SNAP encaps ? */
@ -1019,7 +1019,7 @@ juniper_atm2_if_print(netdissect_options *ndo,
return l2info.header_len;
}
ND_TCHECK2(p[0], 3);
ND_TCHECK_3(p);
if (EXTRACT_BE_U_3(p) == 0xfefe03 || /* NLPID encaps ? */
EXTRACT_BE_U_3(p) == 0xaaaa03) { /* SNAP encaps ? */
@ -1194,7 +1194,7 @@ juniper_parse_header(netdissect_options *ndo,
l2info->length = h->len;
l2info->caplen = h->caplen;
ND_TCHECK2(p[0], 4);
ND_TCHECK_4(p);
l2info->flags = p[3];
l2info->direction = p[3]&JUNIPER_BPF_PKT_IN;
@ -1219,7 +1219,7 @@ juniper_parse_header(netdissect_options *ndo,
tptr = p+jnx_header_len;
/* ok to read extension length ? */
ND_TCHECK2(tptr[0], 2);
ND_TCHECK_2(tptr);
jnx_ext_len = EXTRACT_BE_U_2(tptr);
jnx_header_len += 2;
tptr +=2;
@ -1302,7 +1302,7 @@ juniper_parse_header(netdissect_options *ndo,
* perform the v4/v6 heuristics
* to figure out what it is
*/
ND_TCHECK2(p[jnx_header_len + 4], 1);
ND_TCHECK_1(p + (jnx_header_len + 4));
if (ip_heuristic_guess(ndo, p + jnx_header_len + 4,
l2info->length - (jnx_header_len + 4)) == 0)
ND_PRINT((ndo, "no IP-hdr found!"));
@ -1399,7 +1399,7 @@ juniper_parse_header(netdissect_options *ndo,
case DLT_JUNIPER_MLFR:
switch (l2info->cookie_type) {
case LS_COOKIE_ID:
ND_TCHECK2(p[0], 2);
ND_TCHECK_2(p);
l2info->bundle = l2info->cookie[1];
l2info->proto = EXTRACT_BE_U_2(p);
l2info->header_len += 2;
@ -1423,7 +1423,7 @@ juniper_parse_header(netdissect_options *ndo,
case DLT_JUNIPER_MFR:
switch (l2info->cookie_type) {
case LS_COOKIE_ID:
ND_TCHECK2(p[0], 2);
ND_TCHECK_2(p);
l2info->bundle = l2info->cookie[1];
l2info->proto = EXTRACT_BE_U_2(p);
l2info->header_len += 2;
@ -1442,7 +1442,7 @@ juniper_parse_header(netdissect_options *ndo,
#endif
#ifdef DLT_JUNIPER_ATM2
case DLT_JUNIPER_ATM2:
ND_TCHECK2(p[0], 4);
ND_TCHECK_4(p);
/* ATM cell relay control word present ? */
if (l2info->cookie[7] & ATM2_PKT_TYPE_MASK) {
control_word = EXTRACT_BE_U_4(p);

View File

@ -777,7 +777,7 @@ l2tp_print(netdissect_options *ndo, const u_char *dat, u_int length)
flag_t = flag_l = flag_s = flag_o = FALSE;
ND_TCHECK2(*ptr, 2); /* Flags & Version */
ND_TCHECK_2(ptr); /* Flags & Version */
if ((EXTRACT_BE_U_2(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2TP) {
ND_PRINT((ndo, " l2tp:"));
} else if ((EXTRACT_BE_U_2(ptr) & L2TP_VERSION_MASK) == L2TP_VERSION_L2F) {
@ -813,7 +813,7 @@ l2tp_print(netdissect_options *ndo, const u_char *dat, u_int length)
cnt += 2;
if (flag_l) {
ND_TCHECK2(*ptr, 2); /* Length */
ND_TCHECK_2(ptr); /* Length */
l2tp_len = EXTRACT_BE_U_2(ptr);
ptr += 2;
cnt += 2;
@ -821,28 +821,28 @@ l2tp_print(netdissect_options *ndo, const u_char *dat, u_int length)
l2tp_len = 0;
}
ND_TCHECK2(*ptr, 2); /* Tunnel ID */
ND_TCHECK_2(ptr); /* Tunnel ID */
ND_PRINT((ndo, "(%u/", EXTRACT_BE_U_2(ptr)));
ptr += 2;
cnt += 2;
ND_TCHECK2(*ptr, 2); /* Session ID */
ND_TCHECK_2(ptr); /* Session ID */
ND_PRINT((ndo, "%u)", EXTRACT_BE_U_2(ptr)));
ptr += 2;
cnt += 2;
if (flag_s) {
ND_TCHECK2(*ptr, 2); /* Ns */
ND_TCHECK_2(ptr); /* Ns */
ND_PRINT((ndo, "Ns=%u,", EXTRACT_BE_U_2(ptr)));
ptr += 2;
cnt += 2;
ND_TCHECK2(*ptr, 2); /* Nr */
ND_TCHECK_2(ptr); /* Nr */
ND_PRINT((ndo, "Nr=%u", EXTRACT_BE_U_2(ptr)));
ptr += 2;
cnt += 2;
}
if (flag_o) {
ND_TCHECK2(*ptr, 2); /* Offset Size */
ND_TCHECK_2(ptr); /* Offset Size */
pad = EXTRACT_BE_U_2(ptr);
ptr += (2 + pad);
cnt += (2 + pad);

View File

@ -306,13 +306,13 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
switch (eid_afi) {
case IPv4_AFI:
ND_TCHECK2(*(packet_iterator + packet_offset), 4);
ND_TCHECK_4(packet_iterator + packet_offset);
ND_PRINT((ndo, " EID %s/%u,", ipaddr_string(ndo,
packet_iterator + packet_offset), mask_len));
packet_offset += 4;
break;
case IPv6_AFI:
ND_TCHECK2(*(packet_iterator + packet_offset), 16);
ND_TCHECK_16(packet_iterator + packet_offset);
ND_PRINT((ndo, " EID %s/%u,", ip6addr_string(ndo,
packet_iterator + packet_offset), mask_len));
packet_offset += 16;
@ -339,12 +339,12 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
switch (loc_afi) {
case IPv4_AFI:
ND_TCHECK2(*(packet_iterator + packet_offset), 4);
ND_TCHECK_4(packet_iterator + packet_offset);
ND_PRINT((ndo, " LOC %s", ipaddr_string(ndo, loc_ip_pointer)));
packet_offset += 4;
break;
case IPv6_AFI:
ND_TCHECK2(*(packet_iterator + packet_offset), 16);
ND_TCHECK_16(packet_iterator + packet_offset);
ND_PRINT((ndo, " LOC %s", ip6addr_string(ndo, loc_ip_pointer)));
packet_offset += 16;
break;

View File

@ -425,7 +425,7 @@ snap_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
register u_short et;
register int ret;
ND_TCHECK2(*p, 5);
ND_TCHECK_5(p);
if (caplen < 5 || length < 5)
goto trunc;
orgcode = EXTRACT_BE_U_3(p);

View File

@ -63,7 +63,7 @@ loopback_message_print(netdissect_options *ndo, const u_char *cp, const u_int le
if (len < 2)
goto invalid;
/* function */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
function = EXTRACT_LE_U_2(cp);
cp += 2;
ND_PRINT((ndo, ", %s", tok2str(fcode_str, " invalid (%u)", function)));
@ -73,7 +73,7 @@ loopback_message_print(netdissect_options *ndo, const u_char *cp, const u_int le
if (len < 4)
goto invalid;
/* receipt number */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
ND_PRINT((ndo, ", receipt number %u", EXTRACT_LE_U_2(cp)));
cp += 2;
/* data */
@ -115,7 +115,7 @@ loopback_print(netdissect_options *ndo, const u_char *cp, const u_int len)
if (len < 2)
goto invalid;
/* skipCount */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
skipCount = EXTRACT_LE_U_2(cp);
cp += 2;
ND_PRINT((ndo, ", skipCount %u", skipCount));

View File

@ -175,7 +175,7 @@ lwapp_control_print(netdissect_options *ndo,
if (has_ap_ident) {
/* check if enough bytes for AP identity */
ND_TCHECK2(*tptr, 6);
ND_TCHECK_6(tptr);
lwapp_trans_header = (const struct lwapp_transport_header *)(pptr+6);
} else {
lwapp_trans_header = (const struct lwapp_transport_header *)pptr;
@ -295,7 +295,7 @@ lwapp_data_print(netdissect_options *ndo,
tptr=pptr;
/* check if enough bytes for AP identity */
ND_TCHECK2(*tptr, 6);
ND_TCHECK_6(tptr);
lwapp_trans_header = (const struct lwapp_transport_header *)pptr;
ND_TCHECK(*lwapp_trans_header);

View File

@ -323,7 +323,7 @@ mobility_print(netdissect_options *ndo,
ND_PRINT((ndo, " status=%u", mh->ip6m_data8[0]));
/* Reserved */
hlen = IP6M_MINLEN;
ND_TCHECK2(bp[hlen], 16);
ND_TCHECK_16(bp + hlen);
ND_PRINT((ndo, " homeaddr %s", ip6addr_string(ndo, &bp[hlen])));
hlen += 16;
break;

View File

@ -35,7 +35,7 @@ msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
{
unsigned int type, len;
ND_TCHECK2(*sp, 3);
ND_TCHECK_3(sp);
/* See if we think we're at the beginning of a compound packet */
type = *sp;
len = EXTRACT_BE_U_2(sp + 1);
@ -43,7 +43,7 @@ msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
goto trunc; /* not really truncated, but still not decodable */
ND_PRINT((ndo, " msdp:"));
while (length > 0) {
ND_TCHECK2(*sp, 3);
ND_TCHECK_3(sp);
type = *sp;
len = EXTRACT_BE_U_2(sp + 1);
if (len > 1400 || ndo->ndo_vflag)
@ -72,7 +72,7 @@ msdp_print(netdissect_options *ndo, const u_char *sp, u_int length)
break;
case 2:
ND_PRINT((ndo, " SA-Request"));
ND_TCHECK2(*sp, 5);
ND_TCHECK_5(sp);
ND_PRINT((ndo, " for %s", ipaddr_string(ndo, sp + 1)));
break;
case 4:

View File

@ -623,7 +623,7 @@ olsr_print(netdissect_options *ndo,
if (msg_tlen < 4)
goto trunc;
ND_TCHECK2(*msg_data, 4);
ND_TCHECK_4(msg_data);
name_entries = EXTRACT_BE_U_2(msg_data + 2);
addr_size = 4;
@ -650,7 +650,7 @@ olsr_print(netdissect_options *ndo,
if (msg_tlen < 4)
break;
ND_TCHECK2(*msg_data, 4);
ND_TCHECK_4(msg_data);
name_entry_type = EXTRACT_BE_U_2(msg_data);
name_entry_len = EXTRACT_BE_U_2(msg_data + 2);

File diff suppressed because it is too large Load Diff

View File

@ -85,19 +85,19 @@ of_header_body_print(netdissect_options *ndo, const u_char *cp, const u_char *ep
if (ep < cp + OF_HEADER_LEN)
goto invalid;
/* version */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
version = *cp;
cp += 1;
/* type */
ND_TCHECK2(*cp, 1);
ND_TCHECK_1(cp);
type = *cp;
cp += 1;
/* length */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
length = EXTRACT_BE_U_2(cp);
cp += 2;
/* xid */
ND_TCHECK2(*cp, 4);
ND_TCHECK_4(cp);
xid = EXTRACT_BE_U_4(cp);
cp += 4;
/* Message length includes the header length and a message always includes

View File

@ -922,24 +922,24 @@ ospf_decode_lls(netdissect_options *ndo,
ND_PRINT((ndo, "\n\t[LLS truncated]"));
return (1);
}
ND_TCHECK2(*dptr, 2);
ND_TCHECK_2(dptr);
ND_PRINT((ndo, "\n\t LLS: checksum: 0x%04x", (u_int) EXTRACT_BE_U_2(dptr)));
dptr += 2;
ND_TCHECK2(*dptr, 2);
ND_TCHECK_2(dptr);
length2 = EXTRACT_BE_U_2(dptr);
ND_PRINT((ndo, ", length: %u", length2));
dptr += 2;
ND_TCHECK(*dptr);
while (dptr < dataend) {
ND_TCHECK2(*dptr, 2);
ND_TCHECK_2(dptr);
lls_type = EXTRACT_BE_U_2(dptr);
ND_PRINT((ndo, "\n\t %s (%u)",
tok2str(ospf_lls_tlv_values,"Unknown TLV",lls_type),
lls_type));
dptr += 2;
ND_TCHECK2(*dptr, 2);
ND_TCHECK_2(dptr);
lls_len = EXTRACT_BE_U_2(dptr);
ND_PRINT((ndo, ", length: %u", lls_len));
dptr += 2;
@ -950,7 +950,7 @@ ospf_decode_lls(netdissect_options *ndo,
ND_PRINT((ndo, " [should be 4]"));
lls_len = 4;
}
ND_TCHECK2(*dptr, 4);
ND_TCHECK_4(dptr);
lls_flags = EXTRACT_BE_U_4(dptr);
ND_PRINT((ndo, "\n\t Options: 0x%08x [%s]", lls_flags,
bittok2str(ospf_lls_eo_options, "?", lls_flags)));
@ -962,7 +962,7 @@ ospf_decode_lls(netdissect_options *ndo,
ND_PRINT((ndo, " [should be 20]"));
lls_len = 20;
}
ND_TCHECK2(*dptr, 4);
ND_TCHECK_4(dptr);
ND_PRINT((ndo, "\n\t Sequence number: 0x%08x", EXTRACT_BE_U_4(dptr)));
break;
}

View File

@ -856,11 +856,11 @@ ospf6_print_lls(netdissect_options *ndo,
if (len < OSPF_LLS_HDRLEN)
goto trunc;
/* Checksum */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
ND_PRINT((ndo, "\n\tLLS Checksum 0x%04x", EXTRACT_BE_U_2(cp)));
cp += 2;
/* LLS Data Length */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
llsdatalen = EXTRACT_BE_U_2(cp);
ND_PRINT((ndo, ", Data Length %u", llsdatalen));
if (llsdatalen < OSPF_LLS_HDRLEN || llsdatalen > len)
@ -887,29 +887,29 @@ ospf6_decode_at(netdissect_options *ndo,
if (len < OSPF6_AT_HDRLEN)
goto trunc;
/* Authentication Type */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
ND_PRINT((ndo, "\n\tAuthentication Type %s", tok2str(ospf6_auth_type_str, "unknown (0x%04x)", EXTRACT_BE_U_2(cp))));
cp += 2;
/* Auth Data Len */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
authdatalen = EXTRACT_BE_U_2(cp);
ND_PRINT((ndo, ", Length %u", authdatalen));
if (authdatalen < OSPF6_AT_HDRLEN || authdatalen > len)
goto trunc;
cp += 2;
/* Reserved */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
cp += 2;
/* Security Association ID */
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
ND_PRINT((ndo, ", SAID %u", EXTRACT_BE_U_2(cp)));
cp += 2;
/* Cryptographic Sequence Number (High-Order 32 Bits) */
ND_TCHECK2(*cp, 4);
ND_TCHECK_4(cp);
ND_PRINT((ndo, ", CSN 0x%08x", EXTRACT_BE_U_4(cp)));
cp += 4;
/* Cryptographic Sequence Number (Low-Order 32 Bits) */
ND_TCHECK2(*cp, 4);
ND_TCHECK_4(cp);
ND_PRINT((ndo, ":%08x", EXTRACT_BE_U_4(cp)));
cp += 4;
/* Authentication Data */

View File

@ -54,11 +54,11 @@ otv_print(netdissect_options *ndo, const u_char *bp, u_int len)
ND_PRINT((ndo, "flags [%s] (0x%02x), ", flags & 0x08 ? "I" : ".", flags));
bp += 1;
ND_TCHECK2(*bp, 3);
ND_TCHECK_3(bp);
ND_PRINT((ndo, "overlay %u, ", EXTRACT_BE_U_3(bp)));
bp += 3;
ND_TCHECK2(*bp, 3);
ND_TCHECK_3(bp);
ND_PRINT((ndo, "instance %u\n", EXTRACT_BE_U_3(bp)));
bp += 3;

View File

@ -459,7 +459,7 @@ pgm_print(netdissect_options *ndo,
ND_PRINT((ndo, "[Total option length leaves no room for final option]"));
return;
}
if (!ND_TTEST2(*bp, 2)) {
if (!ND_TTEST_2(bp)) {
ND_PRINT((ndo, " [|OPT]"));
return;
}
@ -521,7 +521,7 @@ pgm_print(netdissect_options *ndo,
ND_PRINT((ndo, "[Option length not a multiple of 4]"));
return;
}
ND_TCHECK2(*bp, 4);
ND_TCHECK_4(bp);
ND_PRINT((ndo, " %u", EXTRACT_BE_U_4(bp)));
bp += 4;
opt_len -= 4;

View File

@ -179,7 +179,7 @@ pimv1_join_prune_print(netdissect_options *ndo,
len -= 4;
if (len < 4)
goto trunc;
ND_TCHECK2(bp[2], 2);
ND_TCHECK_2(bp + 2);
if (ndo->ndo_vflag > 1)
ND_PRINT((ndo, "\n"));
ND_PRINT((ndo, " Hold time: "));
@ -191,7 +191,7 @@ pimv1_join_prune_print(netdissect_options *ndo,
if (len < 4)
goto trunc;
ND_TCHECK2(bp[0], 4);
ND_TCHECK_4(bp);
ngroups = bp[3];
bp += 4;
len -= 4;
@ -215,7 +215,7 @@ pimv1_join_prune_print(netdissect_options *ndo,
len -= 4;
if (len < 4)
goto trunc;
ND_TCHECK2(bp[0], 4);
ND_TCHECK_4(bp);
njoin = EXTRACT_BE_U_2(bp);
nprune = EXTRACT_BE_U_2(bp + 2);
ND_PRINT((ndo, " joined: %d pruned: %d", njoin, nprune));
@ -230,7 +230,7 @@ pimv1_join_prune_print(netdissect_options *ndo,
type = "Prune";
if (len < 6)
goto trunc;
ND_TCHECK2(bp[0], 6);
ND_TCHECK_6(bp);
ND_PRINT((ndo, "\n\t%s %s%s%s%s/%d", type,
(bp[0] & 0x01) ? "Sparse " : "Dense ",
(bp[1] & 0x80) ? "WC " : "",
@ -276,7 +276,7 @@ pimv1_print(netdissect_options *ndo,
}
}
if (ndo->ndo_vflag) {
ND_TCHECK2(bp[10],2);
ND_TCHECK_2(bp + 10);
ND_PRINT((ndo, " (Hold-time "));
unsigned_relts_print(ndo, EXTRACT_BE_U_2(bp + 10));
ND_PRINT((ndo, ")"));
@ -295,7 +295,7 @@ pimv1_print(netdissect_options *ndo,
break;
case PIMV1_TYPE_RP_REACHABILITY:
if (ndo->ndo_vflag) {
ND_TCHECK2(bp[22], 2);
ND_TCHECK_2(bp + 22);
ND_PRINT((ndo, " group %s", ipaddr_string(ndo, &bp[8])));
if (EXTRACT_BE_U_4(bp + 12) != 0xffffffff)
ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[12])));
@ -309,7 +309,7 @@ pimv1_print(netdissect_options *ndo,
ipaddr_string(ndo, &bp[8])));
if (EXTRACT_BE_U_4(bp + 12) != 0xffffffff)
ND_PRINT((ndo, "/%s", ipaddr_string(ndo, &bp[12])));
ND_TCHECK2(bp[24], 4);
ND_TCHECK_4(bp + 24);
ND_PRINT((ndo, " %s pref %d metric %d",
(bp[20] & 0x80) ? "RP-tree" : "SPT",
EXTRACT_BE_U_4(bp + 20) & 0x7fffffff,
@ -369,7 +369,7 @@ cisco_autorp_print(netdissect_options *ndo,
ND_TCHECK(bp[1]);
numrps = bp[1];
ND_TCHECK2(bp[2], 2);
ND_TCHECK_2(bp + 2);
ND_PRINT((ndo, " Hold "));
hold = EXTRACT_BE_U_2(bp + 2);
if (hold)
@ -400,7 +400,7 @@ cisco_autorp_print(netdissect_options *ndo,
if (len < 4)
goto trunc;
ND_TCHECK2(bp[0], 4);
ND_TCHECK_4(bp);
ND_PRINT((ndo, " RP %s", ipaddr_string(ndo, bp)));
bp += 4;
len -= 4;
@ -431,7 +431,7 @@ cisco_autorp_print(netdissect_options *ndo,
for (; nentries; nentries--) {
if (len < 6)
goto trunc;
ND_TCHECK2(bp[0], 6);
ND_TCHECK_6(bp);
ND_PRINT((ndo, "%c%s%s/%d", s, bp[0] & 1 ? "!" : "",
ipaddr_string(ndo, &bp[2]), bp[1]));
if (bp[0] & 0x02) {
@ -759,7 +759,7 @@ pimv2_print(netdissect_options *ndo,
while (len > 0) {
if (len < 4)
goto trunc;
ND_TCHECK2(bp[0], 4);
ND_TCHECK_4(bp);
otype = EXTRACT_BE_U_2(bp);
olen = EXTRACT_BE_U_2(bp + 2);
ND_PRINT((ndo, "\n\t %s Option (%u), length %u, Value: ",
@ -975,7 +975,7 @@ pimv2_print(netdissect_options *ndo,
}
if (len < 4)
goto trunc;
ND_TCHECK2(*bp, 4);
ND_TCHECK_4(bp);
ngroup = bp[1];
holdtime = EXTRACT_BE_U_2(bp + 2);
ND_PRINT((ndo, "\n\t %u group(s)", ngroup));
@ -994,7 +994,7 @@ pimv2_print(netdissect_options *ndo,
bp += advance; len -= advance;
if (len < 4)
goto trunc;
ND_TCHECK2(*bp, 4);
ND_TCHECK_4(bp);
njoin = EXTRACT_BE_U_2(bp);
nprune = EXTRACT_BE_U_2(bp + 2);
ND_PRINT((ndo, ", joined sources: %u, pruned sources: %u", njoin, nprune));
@ -1107,7 +1107,7 @@ pimv2_print(netdissect_options *ndo,
bp += advance; len -= advance;
if (len < 8)
goto trunc;
ND_TCHECK2(*bp, 8);
ND_TCHECK_8(bp);
if (bp[0] & 0x80)
ND_PRINT((ndo, " RPT"));
ND_PRINT((ndo, " pref=%u", EXTRACT_BE_U_4(bp) & 0x7fffffff));

View File

@ -426,7 +426,7 @@ handle_ctrl_proto(netdissect_options *ndo,
if (length < 4) /* FIXME weak boundary checking */
goto trunc;
ND_TCHECK2(*tptr, 2);
ND_TCHECK_2(tptr);
code = EXTRACT_U_1(tptr);
tptr++;
@ -597,7 +597,7 @@ print_lcp_config_options(netdissect_options *ndo,
if (length < 2)
return 0;
ND_TCHECK2(*p, 2);
ND_TCHECK_2(p);
opt = EXTRACT_U_1(p);
len = EXTRACT_U_1(p + 1);
if (length < len)
@ -743,7 +743,7 @@ print_lcp_config_options(netdissect_options *ndo,
ND_PRINT((ndo, " (length bogus, should be = 7)"));
return 0;
}
ND_TCHECK2(*(p + 3), 4);
ND_TCHECK_4(p + 3);
ND_PRINT((ndo, ": IPv4 %s", ipaddr_string(ndo, p + 3)));
break;
case MEDCLASS_MAC:
@ -751,7 +751,7 @@ print_lcp_config_options(netdissect_options *ndo,
ND_PRINT((ndo, " (length bogus, should be = 9)"));
return 0;
}
ND_TCHECK2(*(p + 3), 6);
ND_TCHECK_6(p + 3);
ND_PRINT((ndo, ": MAC %s", etheraddr_string(ndo, p + 3)));
break;
case MEDCLASS_MNB:
@ -1048,7 +1048,7 @@ print_ipcp_config_options(netdissect_options *ndo,
if (length < 2)
return 0;
ND_TCHECK2(*p, 2);
ND_TCHECK_2(p);
opt = EXTRACT_U_1(p);
len = EXTRACT_U_1(p + 1);
if (length < len)
@ -1072,7 +1072,7 @@ print_ipcp_config_options(netdissect_options *ndo,
ND_PRINT((ndo, " (length bogus, should be = 10)"));
return len;
}
ND_TCHECK2(*(p + 6), 4);
ND_TCHECK_4(p + 6);
ND_PRINT((ndo, ": src %s, dst %s",
ipaddr_string(ndo, p + 2),
ipaddr_string(ndo, p + 6)));
@ -1117,7 +1117,7 @@ print_ipcp_config_options(netdissect_options *ndo,
ND_PRINT((ndo, "\n\t Suboptions, length %u", ipcomp_subopttotallen));
while (ipcomp_subopttotallen >= 2) {
ND_TCHECK2(*p, 2);
ND_TCHECK_2(p);
ipcomp_subopt = EXTRACT_U_1(p);
ipcomp_suboptlen = EXTRACT_U_1(p + 1);
@ -1154,7 +1154,7 @@ print_ipcp_config_options(netdissect_options *ndo,
ND_PRINT((ndo, " (length bogus, should be = 6)"));
return 0;
}
ND_TCHECK2(*(p + 2), 4);
ND_TCHECK_4(p + 2);
ND_PRINT((ndo, ": %s", ipaddr_string(ndo, p + 2)));
break;
default:
@ -1184,7 +1184,7 @@ print_ip6cp_config_options(netdissect_options *ndo,
if (length < 2)
return 0;
ND_TCHECK2(*p, 2);
ND_TCHECK_2(p);
opt = EXTRACT_U_1(p);
len = EXTRACT_U_1(p + 1);
if (length < len)
@ -1208,7 +1208,7 @@ print_ip6cp_config_options(netdissect_options *ndo,
ND_PRINT((ndo, " (length bogus, should be = 10)"));
return len;
}
ND_TCHECK2(*(p + 2), 8);
ND_TCHECK_8(p + 2);
ND_PRINT((ndo, ": %04x:%04x:%04x:%04x",
EXTRACT_BE_U_2(p + 2),
EXTRACT_BE_U_2(p + 4),
@ -1244,7 +1244,7 @@ print_ccp_config_options(netdissect_options *ndo,
if (length < 2)
return 0;
ND_TCHECK2(*p, 2);
ND_TCHECK_2(p);
opt = EXTRACT_U_1(p);
len = EXTRACT_U_1(p + 1);
if (length < len)
@ -1343,7 +1343,7 @@ print_bacp_config_options(netdissect_options *ndo,
if (length < 2)
return 0;
ND_TCHECK2(*p, 2);
ND_TCHECK_2(p);
opt = EXTRACT_U_1(p);
len = EXTRACT_U_1(p + 1);
if (length < len)

View File

@ -141,7 +141,7 @@ pppoe_print(netdissect_options *ndo, register const u_char *bp, u_int length)
* tag_type is previous tag or 0xffff for first iteration
*/
while (tag_type && p < pppoe_payload + pppoe_length) {
ND_TCHECK2(*p, 4);
ND_TCHECK_4(p);
tag_type = EXTRACT_BE_U_2(p);
tag_len = EXTRACT_BE_U_2(p + 2);
p += 4;

View File

@ -655,7 +655,7 @@ print_vendor_attr(netdissect_options *ndo,
if (length < 4)
goto trunc;
ND_TCHECK2(*data, 4);
ND_TCHECK_4(data);
vendor_id = EXTRACT_BE_U_4(data);
data+=4;
length-=4;
@ -665,7 +665,7 @@ print_vendor_attr(netdissect_options *ndo,
vendor_id));
while (length >= 2) {
ND_TCHECK2(*data, 2);
ND_TCHECK_2(data);
vendor_type = *(data);
vendor_length = EXTRACT_U_1(data + 1);
@ -721,7 +721,7 @@ print_attr_num(netdissect_options *ndo,
return;
}
ND_TCHECK2(data[0],4);
ND_TCHECK_4(data);
/* This attribute has standard values */
if (attr_type[attr_code].siz_subtypes)
{
@ -842,7 +842,7 @@ print_attr_address(netdissect_options *ndo,
return;
}
ND_TCHECK2(data[0],4);
ND_TCHECK_4(data);
switch(attr_code)
{
@ -885,7 +885,7 @@ print_attr_address6(netdissect_options *ndo,
return;
}
ND_TCHECK2(data[0], 16);
ND_TCHECK_16(data);
ND_PRINT((ndo, "%s", ip6addr_string(ndo, data)));
@ -949,7 +949,7 @@ print_attr_time(netdissect_options *ndo,
return;
}
ND_TCHECK2(data[0],4);
ND_TCHECK_4(data);
attr_time = EXTRACT_BE_U_4(data);
strlcpy(string, ctime(&attr_time), sizeof(string));
@ -985,11 +985,11 @@ print_attr_strange(netdissect_options *ndo,
return;
}
ND_PRINT((ndo, "User_challenge ("));
ND_TCHECK2(data[0],8);
ND_TCHECK_8(data);
len_data = 8;
PRINT_HEX(len_data, data);
ND_PRINT((ndo, ") User_resp("));
ND_TCHECK2(data[0],8);
ND_TCHECK_8(data);
len_data = 8;
PRINT_HEX(len_data, data);
ND_PRINT((ndo, ")"));
@ -1001,25 +1001,25 @@ print_attr_strange(netdissect_options *ndo,
ND_PRINT((ndo, "ERROR: length %u != 14", length));
return;
}
ND_TCHECK2(data[0],1);
ND_TCHECK_1(data);
if (*data)
ND_PRINT((ndo, "User can change password"));
else
ND_PRINT((ndo, "User cannot change password"));
data++;
ND_TCHECK2(data[0],1);
ND_TCHECK_1(data);
ND_PRINT((ndo, ", Min password length: %d", *data));
data++;
ND_PRINT((ndo, ", created at: "));
ND_TCHECK2(data[0],4);
ND_TCHECK_4(data);
len_data = 4;
PRINT_HEX(len_data, data);
ND_PRINT((ndo, ", expires in: "));
ND_TCHECK2(data[0],4);
ND_TCHECK_4(data);
len_data = 4;
PRINT_HEX(len_data, data);
ND_PRINT((ndo, ", Current Time: "));
ND_TCHECK2(data[0],4);
ND_TCHECK_4(data);
len_data = 4;
PRINT_HEX(len_data, data);
break;
@ -1030,7 +1030,7 @@ print_attr_strange(netdissect_options *ndo,
ND_PRINT((ndo, "ERROR: length %u != 8", length));
return;
}
ND_TCHECK2(data[0],8);
ND_TCHECK_8(data);
len_data = 8;
PRINT_HEX(len_data, data);
break;
@ -1041,7 +1041,7 @@ print_attr_strange(netdissect_options *ndo,
ND_PRINT((ndo, "Error: length %u != 4", length));
return;
}
ND_TCHECK2(data[0],4);
ND_TCHECK_4(data);
error_cause_value = EXTRACT_BE_U_4(data);
ND_PRINT((ndo, "Error cause %u: %s", error_cause_value, tok2str(errorcausetype, "Error-Cause %u not known", error_cause_value)));

View File

@ -114,19 +114,19 @@ rrcp_print(netdissect_options *ndo,
tok2str(opcode_values,"unknown opcode (0x%02x)",rrcp_opcode)));
}
if (rrcp_opcode==1 || rrcp_opcode==2){
ND_TCHECK2(*(cp + RRCP_REG_ADDR_OFFSET), 6);
ND_TCHECK_6(cp + RRCP_REG_ADDR_OFFSET);
ND_PRINT((ndo, " addr=0x%04x, data=0x%08x",
EXTRACT_LE_U_2(cp + RRCP_REG_ADDR_OFFSET),
EXTRACT_LE_U_4(cp + RRCP_REG_DATA_OFFSET)));
}
if (rrcp_proto==1){
ND_TCHECK2(*(cp + RRCP_AUTHKEY_OFFSET), 2);
ND_TCHECK_2(cp + RRCP_AUTHKEY_OFFSET);
ND_PRINT((ndo, ", auth=0x%04x",
EXTRACT_BE_U_2(cp + RRCP_AUTHKEY_OFFSET)));
}
if (rrcp_proto==1 && rrcp_opcode==0 &&
((*(cp + RRCP_OPCODE_ISREPLY_OFFSET)) & RRCP_ISREPLY)){
ND_TCHECK2(*(cp + RRCP_VENDOR_ID_OFFSET), 4);
ND_TCHECK_4(cp + RRCP_VENDOR_ID_OFFSET);
ND_PRINT((ndo, " downlink_port=%d, uplink_port=%d, uplink_mac=%s, vendor_id=%08x ,chip_id=%04x ",
*(cp + RRCP_DOWNLINK_PORT_OFFSET),
*(cp + RRCP_UPLINK_PORT_OFFSET),
@ -134,7 +134,7 @@ rrcp_print(netdissect_options *ndo,
EXTRACT_BE_U_4(cp + RRCP_VENDOR_ID_OFFSET),
EXTRACT_BE_U_2(cp + RRCP_CHIP_ID_OFFSET)));
}else if (rrcp_opcode==1 || rrcp_opcode==2 || rrcp_proto==2){
ND_TCHECK2(*(cp + RRCP_COOKIE2_OFFSET), 4);
ND_TCHECK_4(cp + RRCP_COOKIE2_OFFSET);
ND_PRINT((ndo, ", cookie=0x%08x%08x ",
EXTRACT_BE_U_4(cp + RRCP_COOKIE2_OFFSET),
EXTRACT_BE_U_4(cp + RRCP_COOKIE1_OFFSET)));

View File

@ -500,7 +500,7 @@ rsvp_intserv_print(netdissect_options *ndo,
if (obj_tlen < 4)
return 0;
parameter_id = *(tptr);
ND_TCHECK2(*(tptr + 2), 2);
ND_TCHECK_2(tptr + 2);
parameter_length = EXTRACT_BE_U_2(tptr + 2)<<2; /* convert wordcount to bytecount */
ND_PRINT((ndo, "\n\t Parameter ID: %s (%u), length: %u, Flags: [0x%02x]",
@ -522,7 +522,7 @@ rsvp_intserv_print(netdissect_options *ndo,
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
if (parameter_length == 4) {
ND_TCHECK2(*(tptr + 4), 4);
ND_TCHECK_4(tptr + 4);
ND_PRINT((ndo, "\n\t\tIS hop count: %u", EXTRACT_BE_U_4(tptr + 4)));
}
break;
@ -536,7 +536,7 @@ rsvp_intserv_print(netdissect_options *ndo,
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
if (parameter_length == 4) {
ND_TCHECK2(*(tptr + 4), 4);
ND_TCHECK_4(tptr + 4);
bw.i = EXTRACT_BE_U_4(tptr + 4);
ND_PRINT((ndo, "\n\t\tPath b/w estimate: %.10g Mbps", bw.f / 125000));
}
@ -551,7 +551,7 @@ rsvp_intserv_print(netdissect_options *ndo,
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
if (parameter_length == 4) {
ND_TCHECK2(*(tptr + 4), 4);
ND_TCHECK_4(tptr + 4);
ND_PRINT((ndo, "\n\t\tMinimum path latency: "));
if (EXTRACT_BE_U_4(tptr + 4) == 0xffffffff)
ND_PRINT((ndo, "don't care"));
@ -570,7 +570,7 @@ rsvp_intserv_print(netdissect_options *ndo,
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
if (parameter_length == 4) {
ND_TCHECK2(*(tptr + 4), 4);
ND_TCHECK_4(tptr + 4);
ND_PRINT((ndo, "\n\t\tComposed MTU: %u bytes", EXTRACT_BE_U_4(tptr + 4)));
}
break;
@ -616,7 +616,7 @@ rsvp_intserv_print(netdissect_options *ndo,
*/
if (parameter_length == 8) {
ND_TCHECK2(*(tptr + 4), 8);
ND_TCHECK_8(tptr + 4);
bw.i = EXTRACT_BE_U_4(tptr + 4);
ND_PRINT((ndo, "\n\t\tRate: %.10g Mbps", bw.f / 125000));
ND_PRINT((ndo, "\n\t\tSlack Term: %u", EXTRACT_BE_U_4(tptr + 8)));
@ -628,7 +628,7 @@ rsvp_intserv_print(netdissect_options *ndo,
case 135:
case 136:
if (parameter_length == 4) {
ND_TCHECK2(*(tptr + 4), 4);
ND_TCHECK_4(tptr + 4);
ND_PRINT((ndo, "\n\t\tValue: %u", EXTRACT_BE_U_4(tptr + 4)));
}
break;
@ -1068,7 +1068,7 @@ rsvp_obj_print(netdissect_options *ndo,
while(obj_tlen >= 4 ) {
u_char length;
ND_TCHECK2(*obj_tptr, 4);
ND_TCHECK_4(obj_tptr);
length = EXTRACT_U_1(obj_tptr + 1);
ND_PRINT((ndo, "%s Subobject Type: %s, length %u",
indent,
@ -1090,7 +1090,7 @@ rsvp_obj_print(netdissect_options *ndo,
ND_PRINT((ndo, " ERROR: length != 8"));
goto invalid;
}
ND_TCHECK2(*obj_tptr, 8);
ND_TCHECK_8(obj_tptr);
prefix_length = EXTRACT_U_1(obj_tptr + 6);
if (prefix_length != 32) {
ND_PRINT((ndo, " ERROR: Prefix length %u != 32",
@ -1110,7 +1110,7 @@ rsvp_obj_print(netdissect_options *ndo,
ND_PRINT((ndo, " ERROR: length != 8"));
goto invalid;
}
ND_TCHECK2(*obj_tptr, 8);
ND_TCHECK_8(obj_tptr);
ND_PRINT((ndo, ", Flags: [%s] (%#x), Class-Type: %s (%u), %u",
bittok2str(rsvp_obj_rro_label_flag_values,
"none",

View File

@ -948,7 +948,7 @@ fs_print(netdissect_options *ndo,
{
char a[AFSOPAQUEMAX+1];
FIDOUT();
ND_TCHECK2(bp[0], 4);
ND_TCHECK_4(bp);
i = EXTRACT_BE_U_4(bp);
bp += sizeof(uint32_t);
ND_TCHECK2(bp[0], i);

View File

@ -620,7 +620,7 @@ slow_oam_print(netdissect_options *ndo,
/* Sequence number */
if (tlen < 2)
goto tooshort;
ND_TCHECK2(*tptr, 2);
ND_TCHECK_2(tptr);
ND_PRINT((ndo, "\n\t Sequence Number %u", EXTRACT_BE_U_2(tptr)));
tlen -= 2;
tptr += 2;

View File

@ -113,7 +113,7 @@ trans2_qfsinfo(netdissect_options *ndo,
const char *fmt="";
if (request) {
ND_TCHECK2(*param, 2);
ND_TCHECK_2(param);
level = EXTRACT_LE_U_2(param);
fmt = "InfoLevel=[d]\n";
smb_fdata(ndo, param, fmt, param + pcnt, unicodestr);
@ -181,7 +181,7 @@ print_trans2(netdissect_options *ndo,
ND_TCHECK(words[0]);
if (request) {
ND_TCHECK2(w[14 * 2], 2);
ND_TCHECK_2(w + (14 * 2));
pcnt = EXTRACT_LE_U_2(w + 9 * 2);
param = buf + EXTRACT_LE_U_2(w + 10 * 2);
dcnt = EXTRACT_LE_U_2(w + 11 * 2);
@ -193,7 +193,7 @@ print_trans2(netdissect_options *ndo,
ND_PRINT((ndo, "Trans2Interim\n"));
return;
}
ND_TCHECK2(w[7 * 2], 2);
ND_TCHECK_2(w + (7 * 2));
pcnt = EXTRACT_LE_U_2(w + 3 * 2);
param = buf + EXTRACT_LE_U_2(w + 4 * 2);
dcnt = EXTRACT_LE_U_2(w + 6 * 2);
@ -223,7 +223,7 @@ print_trans2(netdissect_options *ndo,
f2 = fn->descript.rep_f2;
}
ND_TCHECK2(*dat, 2);
ND_TCHECK_2(dat);
bcc = EXTRACT_LE_U_2(dat);
ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (fn->descript.fn)
@ -342,7 +342,7 @@ print_trans(netdissect_options *ndo,
int datalen, paramlen;
if (request) {
ND_TCHECK2(w[12 * 2], 2);
ND_TCHECK_2(w + (12 * 2));
paramlen = EXTRACT_LE_U_2(w + 9 * 2);
param = buf + EXTRACT_LE_U_2(w + 10 * 2);
datalen = EXTRACT_LE_U_2(w + 11 * 2);
@ -352,7 +352,7 @@ print_trans(netdissect_options *ndo,
f3 = "|Param ";
f4 = "|Data ";
} else {
ND_TCHECK2(w[7 * 2], 2);
ND_TCHECK_2(w + (7 * 2));
paramlen = EXTRACT_LE_U_2(w + 3 * 2);
param = buf + EXTRACT_LE_U_2(w + 4 * 2);
datalen = EXTRACT_LE_U_2(w + 6 * 2);
@ -366,7 +366,7 @@ print_trans(netdissect_options *ndo,
smb_fdata(ndo, words + 1, f1, min(words + 1 + 2 * words[0], maxbuf),
unicodestr);
ND_TCHECK2(*data1, 2);
ND_TCHECK_2(data1);
bcc = EXTRACT_LE_U_2(data1);
ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (bcc > 0) {
@ -419,7 +419,7 @@ print_negprot(netdissect_options *ndo,
else
smb_print_data(ndo, words + 1, min(wct * 2, PTR_DIFF(maxbuf, words + 1)));
ND_TCHECK2(*data, 2);
ND_TCHECK_2(data);
bcc = EXTRACT_LE_U_2(data);
ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (bcc > 0) {
@ -464,7 +464,7 @@ print_sesssetup(netdissect_options *ndo,
else
smb_print_data(ndo, words + 1, min(wct * 2, PTR_DIFF(maxbuf, words + 1)));
ND_TCHECK2(*data, 2);
ND_TCHECK_2(data);
bcc = EXTRACT_LE_U_2(data);
ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (bcc > 0) {
@ -505,7 +505,7 @@ print_lockingandx(netdissect_options *ndo,
if (wct)
smb_fdata(ndo, words + 1, f1, maxwords, unicodestr);
ND_TCHECK2(*data, 2);
ND_TCHECK_2(data);
bcc = EXTRACT_LE_U_2(data);
ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (bcc > 0) {
@ -873,14 +873,14 @@ print_smb(netdissect_options *ndo,
int v;
for (i = 0; &words[1 + 2 * i] < maxwords; i++) {
ND_TCHECK2(words[1 + 2 * i], 2);
ND_TCHECK_2(words + (1 + 2 * i));
v = EXTRACT_LE_U_2(words + 1 + 2 * i);
ND_PRINT((ndo, "smb_vwv[%d]=%d (0x%X)\n", i, v, v));
}
}
}
ND_TCHECK2(*data, 2);
ND_TCHECK_2(data);
bcc = EXTRACT_LE_U_2(data);
ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
if (f2) {
@ -902,7 +902,7 @@ print_smb(netdissect_options *ndo,
command = words[1];
if (command == 0xFF)
break;
ND_TCHECK2(words[3], 2);
ND_TCHECK_2(words + 3);
newsmboffset = EXTRACT_LE_U_2(words + 3);
fn = smbfind(command, smb_fns);
@ -1109,7 +1109,7 @@ nbt_udp137_print(netdissect_options *ndo,
const u_char *p;
int total, i;
ND_TCHECK2(data[10], 2);
ND_TCHECK_2(data + 10);
name_trn_id = EXTRACT_BE_U_2(data);
response = (data[2] >> 7);
opcode = (data[2] >> 3) & 0xF;

View File

@ -90,16 +90,16 @@ syslog_print(netdissect_options *ndo,
* severity and facility values
*/
ND_TCHECK2(*pptr, 1);
ND_TCHECK_1(pptr);
if (*(pptr+msg_off) == '<') {
msg_off++;
ND_TCHECK2(*(pptr + msg_off), 1);
ND_TCHECK_1(pptr + msg_off);
while (msg_off <= SYSLOG_MAX_DIGITS &&
*(pptr+msg_off) >= '0' &&
*(pptr+msg_off) <= '9') {
pri = pri * 10 + (*(pptr+msg_off) - '0');
msg_off++;
ND_TCHECK2(*(pptr + msg_off), 1);
ND_TCHECK_1(pptr + msg_off);
}
if (*(pptr+msg_off) != '>') {
ND_PRINT((ndo, "%s", tstr));
@ -132,7 +132,7 @@ syslog_print(netdissect_options *ndo,
/* print the syslog text in verbose mode */
for (; msg_off < len; msg_off++) {
ND_TCHECK2(*(pptr + msg_off), 1);
ND_TCHECK_1(pptr + msg_off);
safeputchar(ndo, *(pptr + msg_off));
}

View File

@ -733,7 +733,7 @@ tcp_print(netdissect_options *ndo,
ldp_print(ndo, bp, length);
}
else if ((IS_SRC_OR_DST_PORT(NFS_PORT)) &&
length >= 4 && ND_TTEST2(*bp, 4)) {
length >= 4 && ND_TTEST_4(bp)) {
/*
* If data present, header length valid, and NFS port used,
* assume NFS.

View File

@ -56,6 +56,7 @@
#include <stdio.h>
#include "netdissect.h"
#include "extract.h"
static const char tstr[] = " [|telnet]";
@ -437,7 +438,7 @@ telnet_parse(netdissect_options *ndo, const u_char *sp, u_int length, int print)
/* IAC SB .... IAC SE */
p = sp;
while (length > (u_int)(p + 1 - sp)) {
ND_TCHECK2(*p, 2);
ND_TCHECK_2(p);
if (p[0] == IAC && p[1] == SE)
break;
p++;

View File

@ -129,7 +129,7 @@ udld_print (netdissect_options *ndo, const u_char *pptr, u_int length)
while (tptr < (pptr+length)) {
ND_TCHECK2(*tptr, 4);
ND_TCHECK_4(tptr);
type = EXTRACT_BE_U_2(tptr);
len = EXTRACT_BE_U_2(tptr + 2);

View File

@ -180,7 +180,7 @@ vtp_print (netdissect_options *ndo,
*
*/
ND_TCHECK2(*tptr, 8);
ND_TCHECK_8(tptr);
ND_PRINT((ndo, "\n\t Config Rev %x, Updater %s",
EXTRACT_BE_U_4(tptr),
ipaddr_string(ndo, tptr+4)));
@ -286,7 +286,7 @@ vtp_print (netdissect_options *ndo,
*/
if (len < 2)
goto trunc;
ND_TCHECK2(*tptr, 2);
ND_TCHECK_2(tptr);
type = *tptr;
tlv_len = EXTRACT_U_1(tptr + 1);
@ -376,7 +376,7 @@ vtp_print (netdissect_options *ndo,
*
*/
ND_TCHECK2(*tptr, 4);
ND_TCHECK_4(tptr);
ND_PRINT((ndo, "\n\tStart value: %u", EXTRACT_BE_U_4(tptr)));
break;

View File

@ -80,7 +80,7 @@ zmtp1_print_frame(netdissect_options *ndo, const u_char *cp, const u_char *ep)
uint8_t flags;
ND_PRINT((ndo, "\n\t"));
ND_TCHECK2(*cp, 1); /* length/0xFF */
ND_TCHECK_1(cp); /* length/0xFF */
if (cp[0] != 0xFF) {
header_len = 1; /* length */
@ -172,7 +172,7 @@ zmtp1_print_intermediate_part(netdissect_options *ndo, const u_char *cp, const u
u_int frame_offset;
uint64_t remaining_len;
ND_TCHECK2(*cp, 2);
ND_TCHECK_2(cp);
frame_offset = EXTRACT_BE_U_2(cp);
ND_PRINT((ndo, "\n\t frame offset 0x%04x", frame_offset));
cp += 2;

View File

@ -132,7 +132,7 @@ name_interpret(netdissect_options *ndo,
if (in >= maxbuf)
return(-1); /* name goes past the end of the buffer */
ND_TCHECK2(*in, 1);
ND_TCHECK_1(in);
len = EXTRACT_U_1(in) / 2;
in++;
@ -142,7 +142,7 @@ name_interpret(netdissect_options *ndo,
return(0);
while (len--) {
ND_TCHECK2(*in, 2);
ND_TCHECK_2(in);
if (in + 1 >= maxbuf)
return(-1); /* name goes past the end of the buffer */
if (in[0] < 'A' || in[0] > 'P' || in[1] < 'A' || in[1] > 'P') {
@ -175,7 +175,7 @@ name_ptr(netdissect_options *ndo,
p = buf + ofs;
if (p >= maxbuf)
return(NULL); /* name goes past the end of the buffer */
ND_TCHECK2(*p, 1);
ND_TCHECK_1(p);
c = *p;
@ -183,7 +183,7 @@ name_ptr(netdissect_options *ndo,
if ((c & 0xC0) == 0xC0) {
uint16_t l;
ND_TCHECK2(*p, 2);
ND_TCHECK_2(p);
if ((p + 1) >= maxbuf)
return(NULL); /* name goes past the end of the buffer */
l = EXTRACT_BE_U_2(p) & 0x3FFF;
@ -194,7 +194,7 @@ name_ptr(netdissect_options *ndo,
p = buf + l;
if (p >= maxbuf)
return(NULL); /* name goes past the end of the buffer */
ND_TCHECK2(*p, 1);
ND_TCHECK_1(p);
}
return(p);
@ -374,7 +374,7 @@ unistr(netdissect_options *ndo,
strsize = *len - 1;
} else {
for (;;) {
ND_TCHECK2(sp[0], 2);
ND_TCHECK_2(sp);
*len += 2;
if (sp[0] == 0 && sp[1] == 0)
break;
@ -406,7 +406,7 @@ unistr(netdissect_options *ndo,
}
} else {
while (strsize != 0) {
ND_TCHECK2(s[0], 2);
ND_TCHECK_2(s);
if (l >= MAX_UNISTR_SIZE)
break;
if (s[1] == 0 && ND_ISPRINT(s[0])) {
@ -450,7 +450,7 @@ smb_fdata1(netdissect_options *ndo,
break;
case 'A':
ND_TCHECK2(buf[0], 2);
ND_TCHECK_2(buf);
write_bits(ndo, EXTRACT_LE_U_2(buf), attrib_fmt);
buf += 2;
fmt++;
@ -504,7 +504,7 @@ smb_fdata1(netdissect_options *ndo,
case 'd':
{
unsigned int x;
ND_TCHECK2(buf[0], 2);
ND_TCHECK_2(buf);
x = reverse ? EXTRACT_BE_U_2(buf) :
EXTRACT_LE_U_2(buf);
ND_PRINT((ndo, "%d (0x%x)", x, x));
@ -515,7 +515,7 @@ smb_fdata1(netdissect_options *ndo,
case 'D':
{
unsigned int x;
ND_TCHECK2(buf[0], 4);
ND_TCHECK_4(buf);
x = reverse ? EXTRACT_BE_U_4(buf) :
EXTRACT_LE_U_4(buf);
ND_PRINT((ndo, "%d (0x%x)", x, x));
@ -526,7 +526,7 @@ smb_fdata1(netdissect_options *ndo,
case 'L':
{
uint64_t x;
ND_TCHECK2(buf[0], 8);
ND_TCHECK_8(buf);
x = reverse ? EXTRACT_BE_U_8(buf) :
EXTRACT_LE_U_8(buf);
ND_PRINT((ndo, "%" PRIu64 " (0x%" PRIx64 ")", x, x));
@ -539,7 +539,7 @@ smb_fdata1(netdissect_options *ndo,
/* Weird mixed-endian length values in 64-bit locks */
uint32_t x1, x2;
uint64_t x;
ND_TCHECK2(buf[0], 8);
ND_TCHECK_8(buf);
x1 = reverse ? EXTRACT_BE_U_4(buf) :
EXTRACT_LE_U_4(buf);
x2 = reverse ? EXTRACT_BE_U_4(buf + 4) :
@ -563,7 +563,7 @@ smb_fdata1(netdissect_options *ndo,
case 'w':
{
unsigned int x;
ND_TCHECK2(buf[0], 2);
ND_TCHECK_2(buf);
x = reverse ? EXTRACT_BE_U_2(buf) :
EXTRACT_LE_U_2(buf);
ND_PRINT((ndo, "0x%X", x));
@ -574,7 +574,7 @@ smb_fdata1(netdissect_options *ndo,
case 'W':
{
unsigned int x;
ND_TCHECK2(buf[0], 4);
ND_TCHECK_4(buf);
x = reverse ? EXTRACT_BE_U_4(buf) :
EXTRACT_LE_U_4(buf);
ND_PRINT((ndo, "0x%X", x));
@ -595,7 +595,7 @@ smb_fdata1(netdissect_options *ndo,
break;
case 'd':
ND_TCHECK2(buf[0], 2);
ND_TCHECK_2(buf);
stringlen = reverse ? EXTRACT_BE_U_2(buf) :
EXTRACT_LE_U_2(buf);
ND_PRINT((ndo, "%u", stringlen));
@ -603,7 +603,7 @@ smb_fdata1(netdissect_options *ndo,
break;
case 'D':
ND_TCHECK2(buf[0], 4);
ND_TCHECK_4(buf);
stringlen = reverse ? EXTRACT_BE_U_4(buf) :
EXTRACT_LE_U_4(buf);
ND_PRINT((ndo, "%u", stringlen));
@ -736,7 +736,7 @@ smb_fdata1(netdissect_options *ndo,
switch (atoi(fmt + 1)) {
case 1:
ND_TCHECK2(buf[0], 4);
ND_TCHECK_4(buf);
x = EXTRACT_LE_U_4(buf);
if (x == 0 || x == 0xFFFFFFFF)
t = 0;
@ -745,7 +745,7 @@ smb_fdata1(netdissect_options *ndo,
buf += 4;
break;
case 2:
ND_TCHECK2(buf[0], 4);
ND_TCHECK_4(buf);
x = EXTRACT_LE_U_4(buf);
if (x == 0 || x == 0xFFFFFFFF)
t = 0;
@ -754,7 +754,7 @@ smb_fdata1(netdissect_options *ndo,
buf += 4;
break;
case 3:
ND_TCHECK2(buf[0], 8);
ND_TCHECK_8(buf);
t = interpret_long_date(buf);
buf += 8;
break;