]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Use more the EXTRACT_8BITS() macro to fetch a one-byte value (22/n)
authorFrancois-Xavier Le Bail <[email protected]>
Wed, 22 Nov 2017 14:27:53 +0000 (15:27 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Wed, 22 Nov 2017 15:02:02 +0000 (16:02 +0100)
In ND_PRINT() macro calls, *p++.

Partial list.

print-cdp.c
print-icmp6.c
print-krb.c
print-l2tp.c
print-mptcp.c
print-ppp.c
smbutil.c

index 37db394d9e87840c2243c2c0468abd072ec246b4..586a5ec8ecbd50985158dff09d869d3e41c42cc1 100644 (file)
@@ -342,8 +342,10 @@ cdp_print_addr(netdissect_options *ndo,
                        if (p + pl > endp)
                                goto trunc;
                        ND_PRINT((ndo, "pt=0x%02x, pl=%d, pb=", EXTRACT_8BITS((p - 2)), pl));
-                       while (pl-- > 0)
-                               ND_PRINT((ndo, " %02x", *p++));
+                       while (pl-- > 0) {
+                               ND_PRINT((ndo, " %02x", EXTRACT_8BITS(p)));
+                               p++;
+                       }
                        ND_TCHECK2(*p, 2);
                        if (p + 2 > endp)
                                goto trunc;
@@ -352,8 +354,10 @@ cdp_print_addr(netdissect_options *ndo,
                        ND_TCHECK2(*p, al);
                        if (p + al > endp)
                                goto trunc;
-                       while (al-- > 0)
-                               ND_PRINT((ndo, " %02x", *p++));
+                       while (al-- > 0) {
+                               ND_PRINT((ndo, " %02x", EXTRACT_8BITS(p)));
+                               p++;
+                       }
                }
                num--;
                if (num)
index 4a8c9d51b9297c17bf24d1f068164791dda6e561..bd920faf0f2fbe1b7563c7faedf32a097eb208a6 100644 (file)
@@ -617,7 +617,8 @@ print_lladdr(netdissect_options *ndo, const uint8_t *p, size_t l)
        while (l > 0 && q < ep) {
                if (q > p)
                         ND_PRINT((ndo,":"));
-               ND_PRINT((ndo,"%02x", *q++));
+               ND_PRINT((ndo,"%02x", EXTRACT_8BITS(q)));
+               q++;
                l--;
        }
 }
index 5dc895fd2ea32c6fe184d176b4afe423c99913de..ef6a83b2c4a638dacf5f14a7954d675ae4ab9397 100644 (file)
@@ -203,10 +203,12 @@ krb4_print(netdissect_options *ndo,
        case AUTH_MSG_APPL_REQUEST:
                cp += 2;
                ND_TCHECK(*cp);
-               ND_PRINT((ndo, "v%d ", *cp++));
+               ND_PRINT((ndo, "v%d ", EXTRACT_8BITS(cp)));
+               cp++;
                PRINT;
                ND_TCHECK(*cp);
-               ND_PRINT((ndo, " (%d)", *cp++));
+               ND_PRINT((ndo, " (%d)", EXTRACT_8BITS(cp)));
+               cp++;
                ND_TCHECK(*cp);
                ND_PRINT((ndo, " (%d)", *cp));
                break;
index 6682d71a6e7b53f67da782ff347b69379857eb48..782c0fea3bf36cb22a0f8f83f8af9cbc1c9c5255 100644 (file)
@@ -268,7 +268,8 @@ print_string(netdissect_options *ndo, const u_char *dat, u_int length)
 {
        u_int i;
        for (i=0; i<length; i++) {
-               ND_PRINT((ndo, "%c", *dat++));
+               ND_PRINT((ndo, "%c", EXTRACT_8BITS(dat)));
+               dat++;
        }
 }
 
@@ -277,7 +278,8 @@ print_octets(netdissect_options *ndo, const u_char *dat, u_int length)
 {
        u_int i;
        for (i=0; i<length; i++) {
-               ND_PRINT((ndo, "%02x", *dat++));
+               ND_PRINT((ndo, "%02x", EXTRACT_8BITS(dat)));
+               dat++;
        }
 }
 
index 6e7154e68e62b207b585f849cce2a6cff85dd0f3..8cca477e140c639214d9390d88ddff8ab26ec462 100644 (file)
@@ -367,8 +367,10 @@ remove_addr_print(netdissect_options *ndo,
 
         opt_len -= 3;
         ND_PRINT((ndo, " id"));
-        while (opt_len--)
-                ND_PRINT((ndo, " %u", *addr_id++));
+        while (opt_len--) {
+                ND_PRINT((ndo, " %u", EXTRACT_8BITS(addr_id)));
+                addr_id++;
+        }
         return 1;
 }
 
index 163de1dfddd8c7953f2cd7e5936216673e5ffee6..0a8a96490336b48cfb1943a57d363de5e0a2a91a 100644 (file)
@@ -883,7 +883,8 @@ handle_chap(netdissect_options *ndo,
                ND_PRINT((ndo, ", Value "));
                for (i = 0; i < val_size; i++) {
                        ND_TCHECK(*p);
-                       ND_PRINT((ndo, "%02x", *p++));
+                       ND_PRINT((ndo, "%02x", EXTRACT_8BITS(p)));
+                       p++;
                }
                name_size = len - (p - p0);
                ND_PRINT((ndo, ", Name "));
index 847979e40e98ac41d9af6abc80c1cd2e745f8423..d18a140f5ca28020382aebf56dd26b702cdae4f8 100644 (file)
--- a/smbutil.c
+++ b/smbutil.c
@@ -685,8 +685,10 @@ smb_fdata1(netdissect_options *ndo,
          {
            int l = atoi(fmt + 1);
            ND_TCHECK2(*buf, l);
-           while (l--)
-               ND_PRINT((ndo, "%02x", *buf++));
+           while (l--) {
+               ND_PRINT((ndo, "%02x", EXTRACT_8BITS(buf)));
+               buf++;
+           }
            fmt++;
            while (isdigit((unsigned char)*fmt))
                fmt++;