]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Use more the EXTRACT_U_1() macro (52/n)
authorFrancois-Xavier Le Bail <[email protected]>
Sat, 9 Dec 2017 11:32:00 +0000 (12:32 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Sat, 9 Dec 2017 13:05:25 +0000 (14:05 +0100)
Assignment, p[n]

20 files changed:
print-babel.c
print-bgp.c
print-calm-fast.c
print-cdp.c
print-fr.c
print-geonet.c
print-hncp.c
print-icmp6.c
print-ip.c
print-isakmp.c
print-juniper.c
print-pim.c
print-pppoe.c
print-sl.c
print-smb.c
print-snmp.c
print-sunatm.c
print-vrrp.c
print-zeromq.c
smbutil.c

index d571bc119649d0e3d6e9d446aafc619ead07d145..5c5ab308170a2d117a669fa2635176ed873fa01e 100644 (file)
@@ -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);
index 83e0194ccad0d3d01e1c03fe712964310fdd8345..5c5d880f8f9b13f1da7ffa103da00cdc8a7aa207 100644 (file)
@@ -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",
index 16b416a3f9a516b122db8fb67ed6349e2c237255..6fa91a8feb2bbea136c5ffc4c12945f7fd16e6d1 100644 (file)
@@ -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;
 
index 0c594843b061c97e2309318401ad61f201116757..364af045eec3f4f9214ccf5d10d72f5b4246a93c 100644 (file)
@@ -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);
index 8c8bf781787870f022ef563b350c3c0a4f4ede65..cd68ae81885d358b069189e7f79bc1c6aefdbe01 100644 (file)
@@ -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),
index e40c65112b3a8b86210ad52277b781fe9b374ad5..b59071910d14d167d3f072a3f0c2587fa06f7519 100644 (file)
@@ -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;
index e459dc768a5300541fbfcc3e13bcfe2640b04e2c..a1341923951411bc9850c668a8a6313d91d2ca93 100644 (file)
@@ -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;
index 2b03d6dbc32a7888f4af63cfb724e156edef2ddd..6a3799b94f0205b9a07291e9372628ad367b141d 100644 (file)
@@ -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);
        }
index 0974fbad7641c7466d584744438da7a24d071e49..036c57cda73f87a54ff83446d962ab8fb5f58487 100644 (file)
@@ -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;
index ba1f8fec2cc0db25ec23c9dd5dcdb595033ed36f..d82c4f2848cc85e0d223d210b39d5e9a8f87ea29 100644 (file)
@@ -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;
index b74f00f539e81f86669b25b7eff6051f208d3dd5..85c38b6c9ac24c11df88de99523defc677c4bc49 100644 (file)
@@ -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)));
                 }
             }
index b6048c776a09516678605712518c6599c4637cbe..26e3356be60dfdc62efac3570bf483c342a0a6d1 100644 (file)
@@ -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);
index 652f82ef1b52a592be0fb35c1e6e9d510f13d379..9c4fdfa7b7344ed1dae78f39e12568cf361aa3f5 100644 (file)
@@ -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;
index 5567007a24d2dfb94746df1156ba44375dc80215..7cac2aa482232f07e34c2c63dd8ded873a65933b 100644 (file)
@@ -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:
index b306cd1d267d0fc497d2ea26c41ec1fe1e5b1adc..1e81fcc8d014dec057aa2e3a7196ea4d05f4e1cc 100644 (file)
@@ -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;
index ee6589606c7b6f86393cef0110d2ab63847372e1..1e098dbd0641d7222a62ab5dc1aab7414f2f623e 100644 (file)
@@ -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));
index c46598d47c81f21eb78161e316980640a6576177..4692c2706997186778d5ab31451eb35fc99881e8 100644 (file)
@@ -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;
index f02b28bde3dc44236b7e80ddd12aa075174bc02a..79e0a586fae0a6e5e1b0b1bd9c7e100189188c17 100644 (file)
@@ -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;
 
index 004750ba7b3df48d48b3d88766327e148c02a326..b53745e51932f348663917e13e7f752ad0a8305e 100644 (file)
@@ -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)
index 7d85efb1c58816082269448e5daab288f097e85f..8f081b7240a9d5ac325af7e6c8a339656dffc851 100644 (file)
--- 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;