From: Francois-Xavier Le Bail Date: Fri, 1 Dec 2017 14:19:56 +0000 (+0100) Subject: Use more the EXTRACT_U_1() macro (39/n) X-Git-Tag: tcpdump-4.99-bp~1688 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/505cd1fe15916e21abd6f2aa43a07bba649689cf Use more the EXTRACT_U_1() macro (39/n) In some macros and functions call, p[n] --- diff --git a/print-802_11.c b/print-802_11.c index a1c5b58a..82480f32 100644 --- a/print-802_11.c +++ b/print-802_11.c @@ -1593,15 +1593,15 @@ handle_action(netdissect_options *ndo, case 0: ND_PRINT((ndo, "Spectrum Management Act#%d", EXTRACT_U_1(p + 1))); break; case 1: ND_PRINT((ndo, "QoS Act#%d", EXTRACT_U_1(p + 1))); break; case 2: ND_PRINT((ndo, "DLS Act#%d", EXTRACT_U_1(p + 1))); break; - case 3: ND_PRINT((ndo, "BA ")); PRINT_BA_ACTION(p[1]); break; - case 7: ND_PRINT((ndo, "HT ")); PRINT_HT_ACTION(p[1]); break; - case 13: ND_PRINT((ndo, "MeshAction ")); PRINT_MESH_ACTION(p[1]); break; + case 3: ND_PRINT((ndo, "BA ")); PRINT_BA_ACTION(EXTRACT_U_1(p + 1)); break; + case 7: ND_PRINT((ndo, "HT ")); PRINT_HT_ACTION(EXTRACT_U_1(p + 1)); break; + case 13: ND_PRINT((ndo, "MeshAction ")); PRINT_MESH_ACTION(EXTRACT_U_1(p + 1)); break; case 14: ND_PRINT((ndo, "MultiohopAction ")); - PRINT_MULTIHOP_ACTION(p[1]); break; + PRINT_MULTIHOP_ACTION(EXTRACT_U_1(p + 1)); break; case 15: ND_PRINT((ndo, "SelfprotectAction ")); - PRINT_SELFPROT_ACTION(p[1]); break; + PRINT_SELFPROT_ACTION(EXTRACT_U_1(p + 1)); break; case 127: ND_PRINT((ndo, "Vendor Act#%d", EXTRACT_U_1(p + 1))); break; default: ND_PRINT((ndo, "Reserved(%d) Act#%d", EXTRACT_U_1(p), EXTRACT_U_1(p + 1))); diff --git a/print-babel.c b/print-babel.c index c9386245..d1931c82 100644 --- a/print-babel.c +++ b/print-babel.c @@ -112,7 +112,9 @@ format_id(const u_char *id) { static char buf[25]; snprintf(buf, 25, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", - id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7]); + EXTRACT_U_1(id), EXTRACT_U_1(id + 1), EXTRACT_U_1(id + 2), + EXTRACT_U_1(id + 3), EXTRACT_U_1(id + 4), EXTRACT_U_1(id + 5), + EXTRACT_U_1(id + 6), EXTRACT_U_1(id + 7)); buf[24] = '\0'; return buf; } @@ -442,7 +444,8 @@ babel_print_v2(netdissect_options *ndo, if(len < 6) goto invalid; txcost = EXTRACT_BE_U_2(message + 4); interval = EXTRACT_BE_U_2(message + 6); - rc = network_address(message[2], message + 8, len - 6, address); + rc = network_address(EXTRACT_U_1(message + 2), message + 8, + len - 6, address); if(rc < 0) { ND_PRINT((ndo, "%s", tstr)); break; } ND_PRINT((ndo, "%s txcost %u interval %s", format_address(ndo, address), txcost, format_interval(interval))); @@ -473,7 +476,8 @@ babel_print_v2(netdissect_options *ndo, u_char nh[16]; ND_PRINT((ndo, "\n\tNext Hop")); if(len < 2) goto invalid; - rc = network_address(message[2], message + 4, len - 2, nh); + rc = network_address(EXTRACT_U_1(message + 2), message + 4, + len - 2, nh); if(rc < 0) goto invalid; ND_PRINT((ndo, " %s", format_address(ndo, nh))); } @@ -498,7 +502,9 @@ babel_print_v2(netdissect_options *ndo, ND_PRINT((ndo, "\n\tUpdate")); if(len < 10) goto invalid; plen = message[4] + (message[2] == 1 ? 96 : 0); - rc = network_prefix(message[2], message[4], message[5], + rc = network_prefix(EXTRACT_U_1(message + 2), + EXTRACT_U_1(message + 4), + EXTRACT_U_1(message + 5), message + 12, message[2] == 1 ? v4_prefix : v6_prefix, len - 10, prefix); @@ -534,7 +540,8 @@ babel_print_v2(netdissect_options *ndo, ND_PRINT((ndo, "\n\tRequest ")); if(len < 2) goto invalid; plen = message[3] + (message[2] == 1 ? 96 : 0); - rc = network_prefix(message[2], message[3], 0, + rc = network_prefix(EXTRACT_U_1(message + 2), + EXTRACT_U_1(message + 3), 0, message + 4, NULL, len - 2, prefix); if(rc < 0) goto invalid; ND_PRINT((ndo, "for %s", @@ -553,7 +560,8 @@ babel_print_v2(netdissect_options *ndo, ND_PRINT((ndo, "\n\tMH-Request ")); if(len < 14) goto invalid; seqno = EXTRACT_BE_U_2(message + 4); - rc = network_prefix(message[2], message[3], 0, + rc = network_prefix(EXTRACT_U_1(message + 2), + EXTRACT_U_1(message + 3), 0, message + 16, NULL, len - 14, prefix); if(rc < 0) goto invalid; plen = message[3] + (message[2] == 1 ? 96 : 0); diff --git a/print-hncp.c b/print-hncp.c index b0315722..676ff278 100644 --- a/print-hncp.c +++ b/print-hncp.c @@ -162,7 +162,8 @@ format_nid(const u_char *data) static int i = 0; i = (i + 1) % 4; snprintf(buf[i], sizeof(buf[i]), "%02x:%02x:%02x:%02x", - data[0], data[1], data[2], data[3]); + EXTRACT_U_1(data), EXTRACT_U_1(data + 1), EXTRACT_U_1(data + 2), + EXTRACT_U_1(data + 3)); return buf[i]; } diff --git a/print-ipx.c b/print-ipx.c index 0c42c54d..7640fa0b 100644 --- a/print-ipx.c +++ b/print-ipx.c @@ -101,7 +101,9 @@ ipxaddr_string(uint32_t net, const u_char *node) static char line[256]; snprintf(line, sizeof(line), "%08x.%02x:%02x:%02x:%02x:%02x:%02x", - net, node[0], node[1], node[2], node[3], node[4], node[5]); + net, EXTRACT_U_1(node), EXTRACT_U_1(node + 1), + EXTRACT_U_1(node + 2), EXTRACT_U_1(node + 3), + EXTRACT_U_1(node + 4), EXTRACT_U_1(node + 5)); return line; } diff --git a/print-isakmp.c b/print-isakmp.c index 8244ac2d..31af3f21 100644 --- a/print-isakmp.c +++ b/print-isakmp.c @@ -1408,7 +1408,7 @@ ikev1_id_print(netdissect_options *ndo, u_char tpay _U_, int i; ND_PRINT((ndo," len=%d ", len)); for (i = 0; i < len; i++) - safeputchar(ndo, data[i]); + safeputchar(ndo, EXTRACT_U_1(data + i)); len = 0; break; } @@ -2261,7 +2261,7 @@ ikev2_ID_print(netdissect_options *ndo, u_char tpay, if(dumpascii) { ND_TCHECK2(*typedata, idtype_len); for(i=0; indo_vflag && 4 < len) { diff --git a/print-stp.c b/print-stp.c index 79e9ae33..ff8ba848 100644 --- a/print-stp.c +++ b/print-stp.c @@ -93,7 +93,9 @@ stp_print_bridge_id(const u_char *p) snprintf(bridge_id_str, sizeof(bridge_id_str), "%.2x%.2x.%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", - p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); + EXTRACT_U_1(p), EXTRACT_U_1(p + 1), EXTRACT_U_1(p + 2), + EXTRACT_U_1(p + 3), EXTRACT_U_1(p + 4), EXTRACT_U_1(p + 5), + EXTRACT_U_1(p + 6), EXTRACT_U_1(p + 7)); return bridge_id_str; } diff --git a/smbutil.c b/smbutil.c index 38bd76de..d7c70eeb 100644 --- a/smbutil.c +++ b/smbutil.c @@ -252,7 +252,7 @@ print_asc(netdissect_options *ndo, { int i; for (i = 0; i < len; i++) - safeputchar(ndo, buf[i]); + safeputchar(ndo, EXTRACT_U_1(buf + i)); } static const char * @@ -393,7 +393,7 @@ unistr(netdissect_options *ndo, ND_TCHECK(s[0]); if (l >= MAX_UNISTR_SIZE) break; - if (ND_ISPRINT(s[0])) + if (ND_ISPRINT(EXTRACT_U_1(s))) buf[l] = s[0]; else { if (s[0] == 0) @@ -409,7 +409,7 @@ unistr(netdissect_options *ndo, ND_TCHECK_2(s); if (l >= MAX_UNISTR_SIZE) break; - if (s[1] == 0 && ND_ISPRINT(s[0])) { + if (s[1] == 0 && ND_ISPRINT(EXTRACT_U_1(s))) { /* It's a printable ASCII character */ buf[l] = s[0]; } else { @@ -444,7 +444,7 @@ smb_fdata1(netdissect_options *ndo, switch (*fmt) { case 'a': ND_TCHECK(buf[0]); - write_bits(ndo, buf[0], attrib_fmt); + write_bits(ndo, EXTRACT_U_1(buf), attrib_fmt); buf++; fmt++; break; @@ -472,7 +472,7 @@ smb_fdata1(netdissect_options *ndo, bitfmt[l] = '\0'; fmt = p + 1; ND_TCHECK(buf[0]); - write_bits(ndo, buf[0], bitfmt); + write_bits(ndo, EXTRACT_U_1(buf), bitfmt); buf++; break; }