From: Francois-Xavier Le Bail Date: Sat, 9 Dec 2017 11:32:00 +0000 (+0100) Subject: Use more the EXTRACT_U_1() macro (52/n) X-Git-Tag: tcpdump-4.99-bp~1658 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/07ac438e08e5ffed3539e10d78f1cfc7d221d591 Use more the EXTRACT_U_1() macro (52/n) Assignment, p[n] --- diff --git a/print-babel.c b/print-babel.c index d571bc11..5c5ab308 100644 --- a/print-babel.c +++ b/print-babel.c @@ -375,7 +375,7 @@ babel_print_v2(netdissect_options *ndo, ND_TCHECK_2(message); ICHECK(i, 2); - len = message[1]; + len = EXTRACT_U_1(message + 1); ND_TCHECK2(*message, 2 + len); ICHECK(i, 2 + len); @@ -606,10 +606,10 @@ babel_print_v2(netdissect_options *ndo, int parsed_len = 10; ND_PRINT((ndo, "\n\tSS-Update")); if(len < 10) goto invalid; - ae = message[2]; - src_plen = message[3]; - plen = message[4]; - omitted = message[5]; + ae = EXTRACT_U_1(message + 2); + src_plen = EXTRACT_U_1(message + 3); + plen = EXTRACT_U_1(message + 4); + omitted = EXTRACT_U_1(message + 5); interval = EXTRACT_BE_U_2(message + 6); seqno = EXTRACT_BE_U_2(message + 8); metric = EXTRACT_BE_U_2(message + 10); @@ -647,9 +647,9 @@ babel_print_v2(netdissect_options *ndo, u_char ae, plen, src_plen, prefix[16], src_prefix[16]; ND_PRINT((ndo, "\n\tSS-Request ")); if(len < 3) goto invalid; - ae = message[2]; - plen = message[3]; - src_plen = message[4]; + ae = EXTRACT_U_1(message + 2); + plen = EXTRACT_U_1(message + 3); + src_plen = EXTRACT_U_1(message + 4); rc = network_prefix(ae, plen, 0, message + 2 + parsed_len, NULL, len - parsed_len, prefix); if(rc < 0) goto invalid; @@ -682,11 +682,11 @@ babel_print_v2(netdissect_options *ndo, const u_char *router_id = NULL; ND_PRINT((ndo, "\n\tSS-MH-Request ")); if(len < 14) goto invalid; - ae = message[2]; - plen = message[3]; + ae = EXTRACT_U_1(message + 2); + plen = EXTRACT_U_1(message + 3); seqno = EXTRACT_BE_U_2(message + 4); - hopc = message[6]; - src_plen = message[7]; + hopc = EXTRACT_U_1(message + 6); + src_plen = EXTRACT_U_1(message + 7); router_id = message + 8; rc = network_prefix(ae, plen, 0, message + 2 + parsed_len, NULL, len - parsed_len, prefix); diff --git a/print-bgp.c b/print-bgp.c index 83e0194c..5c5d880f 100644 --- a/print-bgp.c +++ b/print-bgp.c @@ -540,7 +540,7 @@ decode_prefix4(netdissect_options *ndo, ND_TCHECK_1(pptr); ITEMCHECK(1); - plen = pptr[0]; + plen = EXTRACT_U_1(pptr); if (32 < plen) return -1; itemlen -= 1; @@ -574,7 +574,7 @@ decode_labeled_prefix4(netdissect_options *ndo, /* prefix length and label = 4 bytes */ ND_TCHECK_4(pptr); ITEMCHECK(4); - plen = pptr[0]; /* get prefix length */ + plen = EXTRACT_U_1(pptr); /* get prefix length */ /* this is one of the weirdnesses of rfc3107 the label length (actually the label + COS bits) @@ -771,7 +771,7 @@ decode_rt_routing_info(netdissect_options *ndo, /* NLRI "prefix length" from RFC 2858 Section 4. */ ND_TCHECK_1(pptr); - plen = pptr[0]; /* get prefix length */ + plen = EXTRACT_U_1(pptr); /* get prefix length */ /* NLRI "prefix" (ibid), valid lengths are { 0, 32, 33, ..., 96 } bits. * RFC 4684 Section 4 defines the layout of "origin AS" and "route @@ -825,7 +825,7 @@ decode_labeled_vpn_prefix4(netdissect_options *ndo, u_int plen; ND_TCHECK_1(pptr); - plen = pptr[0]; /* get prefix length */ + plen = EXTRACT_U_1(pptr); /* get prefix length */ if ((24+64) > plen) return -1; @@ -1138,7 +1138,7 @@ decode_prefix6(netdissect_options *ndo, ND_TCHECK_1(pd); ITEMCHECK(1); - plen = pd[0]; + plen = EXTRACT_U_1(pd); if (128 < plen) return -1; itemlen -= 1; @@ -1172,7 +1172,7 @@ decode_labeled_prefix6(netdissect_options *ndo, /* prefix length and label = 4 bytes */ ND_TCHECK_4(pptr); ITEMCHECK(4); - plen = pptr[0]; /* get prefix length */ + plen = EXTRACT_U_1(pptr); /* get prefix length */ if (24 > plen) return -1; @@ -1215,7 +1215,7 @@ decode_labeled_vpn_prefix6(netdissect_options *ndo, u_int plen; ND_TCHECK_1(pptr); - plen = pptr[0]; /* get prefix length */ + plen = EXTRACT_U_1(pptr); /* get prefix length */ if ((24+64) > plen) return -1; @@ -1254,7 +1254,7 @@ decode_clnp_prefix(netdissect_options *ndo, u_int plen; ND_TCHECK_1(pptr); - plen = pptr[0]; /* get prefix length */ + plen = EXTRACT_U_1(pptr); /* get prefix length */ if (152 < plen) return -1; @@ -1284,7 +1284,7 @@ decode_labeled_vpn_clnp_prefix(netdissect_options *ndo, u_int plen; ND_TCHECK_1(pptr); - plen = pptr[0]; /* get prefix length */ + plen = EXTRACT_U_1(pptr); /* get prefix length */ if ((24+64) > plen) return -1; @@ -1606,7 +1606,7 @@ bgp_attr_print(netdissect_options *ndo, tptr +=3; ND_TCHECK_1(tptr); - nhlen = tptr[0]; + nhlen = EXTRACT_U_1(tptr); tlen = nhlen; tptr++; @@ -1739,7 +1739,7 @@ bgp_attr_print(netdissect_options *ndo, tptr += tlen; ND_TCHECK_1(tptr); - snpa = tptr[0]; + snpa = EXTRACT_U_1(tptr); tptr++; if (snpa) { @@ -1907,7 +1907,7 @@ bgp_attr_print(netdissect_options *ndo, case BGPTYPE_MP_UNREACH_NLRI: ND_TCHECK2(tptr[0], BGP_MP_NLRI_MINSIZE); af = EXTRACT_BE_U_2(tptr); - safi = tptr[2]; + safi = EXTRACT_U_1(tptr + 2); ND_PRINT((ndo, "\n\t AFI: %s (%u), %sSAFI: %s (%u)", tok2str(af_values, "Unknown AFI", af), @@ -2347,8 +2347,8 @@ bgp_capabilities_print(netdissect_options *ndo, while (i < caps_len) { ND_TCHECK2(opt[i], BGP_CAP_HEADER_SIZE); - cap_type=opt[i]; - cap_len=opt[i+1]; + cap_type=EXTRACT_U_1(opt + i); + cap_len=EXTRACT_U_1(opt + i + 1); tcap_len=cap_len; ND_PRINT((ndo, "\n\t %s (%u), length: %u", tok2str(bgp_capcode_values, "Unknown", diff --git a/print-calm-fast.c b/print-calm-fast.c index 16b416a3..6fa91a8f 100644 --- a/print-calm-fast.c +++ b/print-calm-fast.c @@ -46,8 +46,8 @@ calm_fast_print(netdissect_options *ndo, const u_char *bp, u_int length, const s ND_TCHECK_2(bp); if (length < 2) goto trunc; - srcNwref = bp[0]; - dstNwref = bp[1]; + srcNwref = EXTRACT_U_1(bp); + dstNwref = EXTRACT_U_1(bp + 1); length -= 2; bp += 2; diff --git a/print-cdp.c b/print-cdp.c index 0c594843..364af045 100644 --- a/print-cdp.c +++ b/print-cdp.c @@ -295,8 +295,8 @@ cdp_print_addr(netdissect_options *ndo, ND_TCHECK_2(p); if (p + 2 > endp) goto trunc; - pt = p[0]; /* type of "protocol" field */ - pl = p[1]; /* length of "protocol" field */ + pt = EXTRACT_U_1(p); /* type of "protocol" field */ + pl = EXTRACT_U_1(p + 1); /* length of "protocol" field */ p += 2; ND_TCHECK_2(p + pl); diff --git a/print-fr.c b/print-fr.c index 8c8bf781..cd68ae81 100644 --- a/print-fr.c +++ b/print-fr.c @@ -472,8 +472,8 @@ mfr_print(netdissect_options *ndo, while (tlen>sizeof(struct ie_tlv_header_t)) { ND_TCHECK2(*tptr, sizeof(struct ie_tlv_header_t)); - ie_type=tptr[0]; - ie_len=tptr[1]; + ie_type=EXTRACT_U_1(tptr); + ie_len=EXTRACT_U_1(tptr + 1); ND_PRINT((ndo, "\n\tIE %s (%u), length %u: ", tok2str(mfr_ctrl_ie_values,"Unknown",ie_type), diff --git a/print-geonet.c b/print-geonet.c index e40c6511..b5907191 100644 --- a/print-geonet.c +++ b/print-geonet.c @@ -64,8 +64,8 @@ print_btp_body(netdissect_options *ndo, const char *msg_type_str; /* Assuming ItsDpuHeader */ - version = bp[0]; - msg_type = bp[1]; + version = EXTRACT_U_1(bp); + msg_type = EXTRACT_U_1(bp + 1); msg_type_str = tok2str(msg_type_values, "unknown (%u)", msg_type); ND_PRINT((ndo, "; ItsPduHeader v:%d t:%d-%s", version, msg_type, msg_type_str)); @@ -133,7 +133,7 @@ geonet_print(netdissect_options *ndo, const u_char *bp, u_int length, hdr_type = bp[1] >> 4; hdr_subtype = bp[1] & 0x0f; payload_length = EXTRACT_BE_U_2(bp + 4); - hop_limit = bp[7]; + hop_limit = EXTRACT_U_1(bp + 7); switch (next_hdr) { case 0: next_hdr_txt = "Any"; break; diff --git a/print-hncp.c b/print-hncp.c index e459dc76..a1341923 100644 --- a/print-hncp.c +++ b/print-hncp.c @@ -242,7 +242,8 @@ print_dns_label(netdissect_options *ndo, { u_int length = 0; while (length < max_length) { - u_int lab_length = cp[length++]; + u_int lab_length = EXTRACT_U_1(cp + length); + length++; if (lab_length == 0) return (int)length; if (length > 1 && print) @@ -274,8 +275,8 @@ dhcpv4_print(netdissect_options *ndo, if (i + 2 > length) return -1; tlv = cp + i; - type = tlv[0]; - optlen = tlv[1]; + type = EXTRACT_U_1(tlv); + optlen = EXTRACT_U_1(tlv + 1); value = tlv + 2; ND_PRINT((ndo, "\n")); @@ -654,7 +655,7 @@ hncp_print_rec(netdissect_options *ndo, ND_PRINT((ndo, " %s", istr)); break; } - policy = value[0]; + policy = EXTRACT_U_1(value); ND_PRINT((ndo, " type: ")); if (policy == 0) { if (bodylen != 1) { @@ -807,7 +808,7 @@ hncp_print_rec(netdissect_options *ndo, ND_PRINT((ndo, " %s", istr)); break; } - l = value[16]; + l = EXTRACT_U_1(value + 16); if (bodylen < 17 + l) { ND_PRINT((ndo, " %s", istr)); break; diff --git a/print-icmp6.c b/print-icmp6.c index 2b03d6db..6a3799b9 100644 --- a/print-icmp6.c +++ b/print-icmp6.c @@ -1498,7 +1498,7 @@ mldv2_query_print(netdissect_options *ndo, const u_char *bp, u_int len) ND_PRINT((ndo," robustness=%d", EXTRACT_U_1(bp + 24) & 0x07)); } if (EXTRACT_U_1(bp + 25) < 128) { - qqi = bp[25]; + qqi = EXTRACT_U_1(bp + 25); } else { qqi = ((bp[25] & 0x0f) | 0x10) << (((bp[25] & 0x70) >> 4) + 3); } diff --git a/print-ip.c b/print-ip.c index 0974fbad..036c57cd 100644 --- a/print-ip.c +++ b/print-ip.c @@ -114,7 +114,7 @@ ip_finddst(netdissect_options *ndo, len = 1; else { ND_TCHECK_1(cp + 1); - len = cp[1]; + len = EXTRACT_U_1(cp + 1); if (len < 2) break; } @@ -266,7 +266,7 @@ ip_optprint(netdissect_options *ndo, else { ND_TCHECK_1(cp + 1); - option_len = cp[1]; + option_len = EXTRACT_U_1(cp + 1); if (option_len < 2) { ND_PRINT((ndo, " [bad length %u]", option_len)); return; diff --git a/print-isakmp.c b/print-isakmp.c index ba1f8fec..d82c4f28 100644 --- a/print-isakmp.c +++ b/print-isakmp.c @@ -987,7 +987,7 @@ ikev1_attr_print(netdissect_options *ndo, const u_char *p, const u_char *ep2) ND_PRINT((ndo,"type=#%d ", t)); if (EXTRACT_U_1(p) & 0x80) { ND_PRINT((ndo,"value=")); - t = p[2]; + t = EXTRACT_U_1(p + 2); if (!rawprint(ndo, (const uint8_t *)(p + 2), 2)) { ND_PRINT((ndo,")")); goto trunc; diff --git a/print-juniper.c b/print-juniper.c index b74f00f5..85c38b6c 100644 --- a/print-juniper.c +++ b/print-juniper.c @@ -1195,7 +1195,7 @@ juniper_parse_header(netdissect_options *ndo, l2info->length = h->len; l2info->caplen = h->caplen; ND_TCHECK_4(p); - l2info->flags = p[3]; + l2info->flags = EXTRACT_U_1(p + 3); l2info->direction = p[3]&JUNIPER_BPF_PKT_IN; if (EXTRACT_BE_U_3(p) != JUNIPER_MGC_NUMBER) { /* magic number found ? */ @@ -1361,7 +1361,7 @@ juniper_parse_header(netdissect_options *ndo, if (ndo->ndo_eflag) ND_PRINT((ndo, ", cookie 0x")); for (idx = 0; idx < l2info->cookie_len; idx++) { - l2info->cookie[idx] = p[idx]; /* copy cookie data */ + l2info->cookie[idx] = EXTRACT_U_1(p + idx); /* copy cookie data */ if (ndo->ndo_eflag) ND_PRINT((ndo, "%02x", EXTRACT_U_1(p + idx))); } } diff --git a/print-pim.c b/print-pim.c index b6048c77..26e3356b 100644 --- a/print-pim.c +++ b/print-pim.c @@ -192,7 +192,7 @@ pimv1_join_prune_print(netdissect_options *ndo, if (len < 4) goto trunc; ND_TCHECK_4(bp); - ngroups = bp[3]; + ngroups = EXTRACT_U_1(bp + 3); bp += 4; len -= 4; while (ngroups--) { @@ -254,7 +254,7 @@ pimv1_print(netdissect_options *ndo, register u_char type; ND_TCHECK_1(bp + 1); - type = bp[1]; + type = EXTRACT_U_1(bp + 1); ND_PRINT((ndo, " %s", tok2str(pimv1_type_str, "[type %u]", type))); switch (type) { @@ -353,7 +353,7 @@ cisco_autorp_print(netdissect_options *ndo, goto trunc; ND_TCHECK_1(bp); ND_PRINT((ndo, " auto-rp ")); - type = bp[0]; + type = EXTRACT_U_1(bp); switch (type) { case 0x11: ND_PRINT((ndo, "candidate-advert")); @@ -367,7 +367,7 @@ cisco_autorp_print(netdissect_options *ndo, } ND_TCHECK_1(bp + 1); - numrps = bp[1]; + numrps = EXTRACT_U_1(bp + 1); ND_TCHECK_2(bp + 2); ND_PRINT((ndo, " Hold ")); @@ -424,7 +424,7 @@ cisco_autorp_print(netdissect_options *ndo, if (len < 1) goto trunc; ND_TCHECK_1(bp); - nentries = bp[0]; + nentries = EXTRACT_U_1(bp); bp += 1; len -= 1; s = ' '; @@ -977,7 +977,7 @@ pimv2_print(netdissect_options *ndo, if (len < 4) goto trunc; ND_TCHECK_4(bp); - ngroup = bp[1]; + ngroup = EXTRACT_U_1(bp + 1); holdtime = EXTRACT_BE_U_2(bp + 2); ND_PRINT((ndo, "\n\t %u group(s)", ngroup)); if (PIM_TYPE(pim->pim_typever) != 7) { /*not for Graft-ACK*/ @@ -1124,7 +1124,7 @@ pimv2_print(netdissect_options *ndo, goto trunc; ND_TCHECK_1(bp); ND_PRINT((ndo, " prefix-cnt=%d", EXTRACT_U_1(bp))); - pfxcnt = bp[0]; + pfxcnt = EXTRACT_U_1(bp); if (len < 2) goto trunc; ND_TCHECK_1(bp + 1); diff --git a/print-pppoe.c b/print-pppoe.c index 652f82ef..9c4fdfa7 100644 --- a/print-pppoe.c +++ b/print-pppoe.c @@ -106,7 +106,7 @@ pppoe_print(netdissect_options *ndo, register const u_char *bp, u_int length) ND_TCHECK2(*pppoe_packet, PPPOE_HDRLEN); pppoe_ver = (pppoe_packet[0] & 0xF0) >> 4; pppoe_type = (pppoe_packet[0] & 0x0F); - pppoe_code = pppoe_packet[1]; + pppoe_code = EXTRACT_U_1(pppoe_packet + 1); pppoe_sessionid = EXTRACT_BE_U_2(pppoe_packet + 2); pppoe_length = EXTRACT_BE_U_2(pppoe_packet + 4); pppoe_payload = pppoe_packet + PPPOE_HDRLEN; diff --git a/print-sl.c b/print-sl.c index 5567007a..7cac2aa4 100644 --- a/print-sl.c +++ b/print-sl.c @@ -130,7 +130,7 @@ sliplink_print(netdissect_options *ndo, int dir; u_int hlen; - dir = p[SLX_DIR]; + dir = EXTRACT_U_1(p + SLX_DIR); switch (dir) { case SLIPDIR_IN: diff --git a/print-smb.c b/print-smb.c index b306cd1d..1e81fcc8 100644 --- a/print-smb.c +++ b/print-smb.c @@ -245,7 +245,7 @@ print_browse(netdissect_options *ndo, int command; ND_TCHECK_1(data); - command = data[0]; + command = EXTRACT_U_1(data); smb_fdata(ndo, param, "BROWSE PACKET\n|Param ", param+paramlen, unicodestr); @@ -401,7 +401,7 @@ print_negprot(netdissect_options *ndo, const char *f1 = NULL, *f2 = NULL; ND_TCHECK_1(words); - wct = words[0]; + wct = EXTRACT_U_1(words); if (request) f2 = "*|Dialect=[Y]\n"; else { @@ -443,7 +443,7 @@ print_sesssetup(netdissect_options *ndo, const char *f1 = NULL, *f2 = NULL; ND_TCHECK_1(words); - wct = words[0]; + wct = EXTRACT_U_1(words); if (request) { if (wct == 10) f1 = "Com2=[w]\nOff2=[d]\nBufSize=[d]\nMpxMax=[d]\nVcNum=[d]\nSessionKey=[W]\nPassLen=[d]\nCryptLen=[d]\nCryptOff=[d]\nPass&Name=\n"; @@ -489,7 +489,7 @@ print_lockingandx(netdissect_options *ndo, const char *f1 = NULL, *f2 = NULL; ND_TCHECK_1(words); - wct = words[0]; + wct = EXTRACT_U_1(words); if (request) { f1 = "Com2=[w]\nOff2=[d]\nHandle=[d]\nLockType=[w]\nTimeOut=[D]\nUnlockCount=[d]\nLockCount=[d]\n"; ND_TCHECK_1(words + 7); @@ -811,7 +811,7 @@ print_smb(netdissect_options *ndo, request = (buf[9] & 0x80) ? 0 : 1; startbuf = buf; - command = buf[4]; + command = EXTRACT_U_1(buf + 4); fn = smbfind(command, smb_fns); @@ -851,7 +851,7 @@ print_smb(netdissect_options *ndo, words = buf + smboffset; ND_TCHECK_1(words); - wct = words[0]; + wct = EXTRACT_U_1(words); data = words + 1 + wct * 2; maxwords = min(data, maxbuf); @@ -900,7 +900,7 @@ print_smb(netdissect_options *ndo, if (wct == 0) break; ND_TCHECK_1(words + 1); - command = words[1]; + command = EXTRACT_U_1(words + 1); if (command == 0xFF) break; ND_TCHECK_2(words + 3); @@ -944,7 +944,7 @@ nbt_tcp_print(netdissect_options *ndo, if (caplen < 4) goto trunc; maxbuf = data + caplen; - type = data[0]; + type = EXTRACT_U_1(data); nbt_len = EXTRACT_BE_U_2(data + 2); length -= 4; caplen -= 4; @@ -976,7 +976,7 @@ nbt_tcp_print(netdissect_options *ndo, goto trunc; if (caplen < 4) goto trunc; - ecode = data[4]; + ecode = EXTRACT_U_1(data + 4); ND_PRINT((ndo, "Session Reject, ")); switch (ecode) { @@ -1049,7 +1049,7 @@ nbt_tcp_print(netdissect_options *ndo, if (data == NULL) break; if (nbt_len >= 1 && caplen >= 1) { - ecode = origdata[4]; + ecode = EXTRACT_U_1(origdata + 4); switch (ecode) { case 0x80: ND_PRINT((ndo, "Not listening on called name\n")); @@ -1189,7 +1189,7 @@ nbt_udp137_print(netdissect_options *ndo, int numnames; ND_TCHECK_1(p); - numnames = p[0]; + numnames = EXTRACT_U_1(p); p = smb_fdata(ndo, p, "NumNames=[B]\n", p + 1, 0); if (p == NULL) goto out; @@ -1387,7 +1387,7 @@ netbeui_print(netdissect_options *ndo, maxbuf = ndo->ndo_snapend; ND_TCHECK_1(data + 4); len = EXTRACT_LE_U_2(data); - command = data[4]; + command = EXTRACT_U_1(data + 4); data2 = data + len; if (data2 >= maxbuf) { data2 = maxbuf; diff --git a/print-snmp.c b/print-snmp.c index ee658960..1e098dbd 100644 --- a/print-snmp.c +++ b/print-snmp.c @@ -1798,7 +1798,7 @@ v3msg_print(netdissect_options *ndo, ND_PRINT((ndo, "[msgFlags size %d]", elem.asnlen)); return; } - flags = elem.data.str[0]; + flags = EXTRACT_U_1(elem.data.str); if (flags != 0x00 && flags != 0x01 && flags != 0x03 && flags != 0x04 && flags != 0x05 && flags != 0x07) { ND_PRINT((ndo, "[msgFlags=0x%02X]", flags)); diff --git a/print-sunatm.c b/print-sunatm.c index c46598d4..4692c270 100644 --- a/print-sunatm.c +++ b/print-sunatm.c @@ -97,7 +97,7 @@ sunatm_if_print(netdissect_options *ndo, } vci = EXTRACT_BE_U_2(p + VCI_POS); - vpi = p[VPI_POS]; + vpi = EXTRACT_U_1(p + VPI_POS); p += PKT_BEGIN_POS; caplen -= PKT_BEGIN_POS; diff --git a/print-vrrp.c b/print-vrrp.c index f02b28bd..79e0a586 100644 --- a/print-vrrp.c +++ b/print-vrrp.c @@ -124,7 +124,7 @@ vrrp_print(netdissect_options *ndo, ND_TCHECK_1(bp + 5); if (version == 2) { - auth_type = bp[4]; + auth_type = EXTRACT_U_1(bp + 4); ND_PRINT((ndo, ", authtype %s", tok2str(auth2str, NULL, auth_type))); ND_PRINT((ndo, ", intvl %us, length %u", EXTRACT_U_1(bp + 5), len)); } else { /* version == 3 */ @@ -133,7 +133,7 @@ vrrp_print(netdissect_options *ndo, } if (ndo->ndo_vflag) { - int naddrs = bp[3]; + int naddrs = EXTRACT_U_1(bp + 3); int i; char c; diff --git a/print-zeromq.c b/print-zeromq.c index 004750ba..b53745e5 100644 --- a/print-zeromq.c +++ b/print-zeromq.c @@ -84,7 +84,7 @@ zmtp1_print_frame(netdissect_options *ndo, const u_char *cp, const u_char *ep) if (EXTRACT_U_1(cp) != 0xFF) { header_len = 1; /* length */ - body_len_declared = cp[0]; + body_len_declared = EXTRACT_U_1(cp); ND_PRINT((ndo, " frame flags+body (8-bit) length %" PRIu64, body_len_declared)); } else { header_len = 1 + 8; /* 0xFF, length */ @@ -96,7 +96,7 @@ zmtp1_print_frame(netdissect_options *ndo, const u_char *cp, const u_char *ep) if (body_len_declared == 0) return cp + header_len; /* skip to the next frame */ ND_TCHECK2(*cp, header_len + 1); /* ..., flags */ - flags = cp[header_len]; + flags = EXTRACT_U_1(cp + header_len); body_len_captured = ep - cp - header_len; if (body_len_declared > body_len_captured) diff --git a/smbutil.c b/smbutil.c index 7d85efb1..8f081b72 100644 --- a/smbutil.c +++ b/smbutil.c @@ -395,7 +395,7 @@ unistr(netdissect_options *ndo, if (l >= MAX_UNISTR_SIZE) break; if (ND_ISPRINT(EXTRACT_U_1(s))) - buf[l] = s[0]; + buf[l] = EXTRACT_U_1(s); else { if (EXTRACT_U_1(s) == 0) break; @@ -412,7 +412,7 @@ unistr(netdissect_options *ndo, break; if (EXTRACT_U_1(s + 1) == 0 && ND_ISPRINT(EXTRACT_U_1(s))) { /* It's a printable ASCII character */ - buf[l] = s[0]; + buf[l] = EXTRACT_U_1(s); } else { /* It's a non-ASCII character or a non-printable ASCII character */ if (EXTRACT_U_1(s) == 0 && EXTRACT_U_1(s + 1) == 0) @@ -496,7 +496,7 @@ smb_fdata1(netdissect_options *ndo, { unsigned int x; ND_TCHECK_1(buf); - x = buf[0]; + x = EXTRACT_U_1(buf); ND_PRINT((ndo, "%u (0x%x)", x, x)); buf += 1; fmt++; @@ -555,7 +555,7 @@ smb_fdata1(netdissect_options *ndo, { unsigned int x; ND_TCHECK_1(buf); - x = buf[0]; + x = EXTRACT_U_1(buf); ND_PRINT((ndo, "0x%X", x)); buf += 1; fmt++; @@ -590,7 +590,7 @@ smb_fdata1(netdissect_options *ndo, case 'b': ND_TCHECK_1(buf); - stringlen = buf[0]; + stringlen = EXTRACT_U_1(buf); ND_PRINT((ndo, "%u", stringlen)); buf += 1; break; @@ -717,7 +717,7 @@ smb_fdata1(netdissect_options *ndo, break; case 2: ND_TCHECK_1(buf + 15); - name_type = buf[15]; + name_type = EXTRACT_U_1(buf + 15); ND_PRINT((ndo, "%-15.15s NameType=0x%02X (%s)", buf, name_type, name_type_str(name_type))); buf += 16;