]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Use more the EXTRACT_8BITS() macro to fetch a one-byte value (17/n)
authorFrancois-Xavier Le Bail <[email protected]>
Tue, 21 Nov 2017 19:23:59 +0000 (20:23 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Tue, 21 Nov 2017 19:30:12 +0000 (20:30 +0100)
Assignment, *p++ -> EXTRACT_8BITS(p); p++;

Partial list.

print-babel.c
print-icmp6.c
print-krb.c
print-lldp.c
print-pgm.c
print-ppp.c
print-sl.c
print-tcp.c

index ae113adb1e0ea8513ec4853d56d522ea9c1297b6..3f5c3d16c5a3c43d6ddd392840066ad33e66ce5f 100644 (file)
@@ -274,14 +274,16 @@ subtlvs_print(netdissect_options *ndo,
     uint32_t t1, t2;
 
     while (cp < ep) {
-        subtype = *cp++;
+        subtype = EXTRACT_8BITS(cp);
+        cp++;
         if(subtype == MESSAGE_SUB_PAD1) {
             ND_PRINT((ndo, " sub-pad1"));
             continue;
         }
         if(cp == ep)
             goto invalid;
-        sublen = *cp++;
+        sublen = EXTRACT_8BITS(cp);
+        cp++;
         if(cp + sublen > ep)
             goto invalid;
 
index aab19971279067475e21c8468e3d6d81fea60020..7c168b7804226801e87a6d972698fc1df3fade49 100644 (file)
@@ -1535,7 +1535,8 @@ dnsname_print(netdissect_options *ndo, const u_char *cp, const u_char *ep)
        /* DNS name decoding - no decompression */
        ND_PRINT((ndo,", \""));
        while (cp < ep) {
-               i = *cp++;
+               i = EXTRACT_8BITS(cp);
+               cp++;
                if (i) {
                        if (i > ep - cp) {
                                ND_PRINT((ndo,"???"));
index 3685ab6c3ca58820e14d4c7e28441a6646d0c692..5dc895fd2ea32c6fe184d176b4afe423c99913de 100644 (file)
@@ -119,7 +119,8 @@ c_print(netdissect_options *ndo,
 
        flag = 1;
        while (s < ep) {
-               c = *s++;
+               c = EXTRACT_8BITS(s);
+               s++;
                if (c == '\0') {
                        flag = 0;
                        break;
index fd016a2ed69416906ec7b1bd5bd3befd65abac71..b06dab6180e8405e687ee7d5021d26d71e1d4ca4 100644 (file)
@@ -1369,7 +1369,8 @@ lldp_mgmt_addr_tlv_print(netdissect_options *ndo,
     if (tlen < 1) {
         return 0;
     }
-    mgmt_addr_len = *tptr++;
+    mgmt_addr_len = EXTRACT_8BITS(tptr);
+    tptr++;
     tlen--;
 
     if (tlen < mgmt_addr_len) {
index e2d721c1a3266971d1ef750ac81078659240e738..94f3465bad9b7d643fb6e77db0fe2d96620ce9f5 100644 (file)
@@ -433,12 +433,14 @@ pgm_print(netdissect_options *ndo,
             * That option header MUST be an OPT_LENGTH option
             * (see the first paragraph of section 9.1 in RFC 3208).
             */
-           opt_type = *bp++;
+           opt_type = EXTRACT_8BITS(bp);
+           bp++;
            if ((opt_type & PGM_OPT_MASK) != PGM_OPT_LENGTH) {
                ND_PRINT((ndo, "[First option bad, should be PGM_OPT_LENGTH, is %u]", opt_type & PGM_OPT_MASK));
                return;
            }
-           opt_len = *bp++;
+           opt_len = EXTRACT_8BITS(bp);
+           bp++;
            if (opt_len != 4) {
                ND_PRINT((ndo, "[Bad OPT_LENGTH option, length %u != 4]", opt_len));
                return;
@@ -461,8 +463,10 @@ pgm_print(netdissect_options *ndo,
                    ND_PRINT((ndo, " [|OPT]"));
                    return;
                }
-               opt_type = *bp++;
-               opt_len = *bp++;
+               opt_type = EXTRACT_8BITS(bp);
+               bp++;
+               opt_len = EXTRACT_8BITS(bp);
+               bp++;
                if (opt_len < PGM_MIN_OPT_LEN) {
                    ND_PRINT((ndo, "[Bad option, length %u < %u]", opt_len,
                        PGM_MIN_OPT_LEN));
index b6723f8544783c3801039fc164a41d22e1948aa7..9ace0e239393ad385d3a525bb37a365f77bed74e 100644 (file)
@@ -429,7 +429,8 @@ handle_ctrl_proto(netdissect_options *ndo,
                goto trunc;
        ND_TCHECK2(*tptr, 2);
 
-       code = *tptr++;
+       code = EXTRACT_8BITS(tptr);
+       tptr++;
 
        ND_PRINT((ndo, "%s (0x%02x), id %u, length %u",
                  tok2str(cpcodes, "Unknown Opcode",code),
@@ -1390,7 +1391,8 @@ ppp_hdlc(netdissect_options *ndo,
         * contents.
         */
        for (s = p, t = b, i = length; i > 0 && ND_TTEST(*s); i--) {
-               c = *s++;
+               c = EXTRACT_8BITS(s);
+               s++;
                if (c == 0x7d) {
                        if (i <= 1 || !ND_TTEST(*s))
                                break;
index e8246e9d710c2f3c3504cb977e9a79ef1477df0f..a4a05fb102dcea02ce300c2cb7e38320422426cb 100644 (file)
@@ -231,9 +231,11 @@ compressed_sl_print(netdissect_options *ndo,
        register const u_char *cp = chdr;
        register u_int flags, hlen;
 
-       flags = *cp++;
+       flags = EXTRACT_8BITS(cp);
+       cp++;
        if (flags & NEW_C) {
-               lastconn = *cp++;
+               lastconn = EXTRACT_8BITS(cp);
+               cp++;
                ND_PRINT((ndo, "ctcp %d", lastconn));
        } else
                ND_PRINT((ndo, "ctcp *"));
index fb7b14a469e826b577cd1fc826c49137435cd9be..793aec245bb45ac159bdd2bc7371d2e39764c86f 100644 (file)
@@ -429,12 +429,14 @@ tcp_print(netdissect_options *ndo,
                         if (ch != '\0')
                                 ND_PRINT((ndo, "%c", ch));
                         ND_TCHECK(*cp);
-                        opt = *cp++;
+                        opt = EXTRACT_8BITS(cp);
+                        cp++;
                         if (ZEROLENOPT(opt))
                                 len = 1;
                         else {
                                 ND_TCHECK(*cp);
-                                len = *cp++;   /* total including type, len */
+                                len = EXTRACT_8BITS(cp);
+                                cp++;  /* total including type, len */
                                 if (len < 2 || len > hlen)
                                         goto bad;
                                 --hlen;                /* account for length byte */
@@ -801,7 +803,8 @@ print_tcp_rst_data(netdissect_options *ndo,
         }
         ND_PRINT((ndo, " "));
         while (length-- && sp < ndo->ndo_snapend) {
-                c = *sp++;
+                c = EXTRACT_8BITS(sp);
+                sp++;
                 safeputchar(ndo, c);
         }
         ND_PRINT((ndo, "]"));