diff options
author | Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> | 2017-11-21 20:23:59 +0100 |
---|---|---|
committer | Francois-Xavier Le Bail <devel.fx.lebail@orange.fr> | 2017-11-21 20:30:12 +0100 |
commit | a7a76012a129ffefb64f102948db63fbc715e45e (patch) | |
tree | 3e02d247b7a74c7fcd82e7f7f1adccd4b5e2277e | |
parent | f7606784dba04b65edbd2f1582465aab2266ce7f (diff) | |
download | tcpdump-a7a76012a129ffefb64f102948db63fbc715e45e.tar.gz |
Use more the EXTRACT_8BITS() macro to fetch a one-byte value (17/n)
Assignment, *p++ -> EXTRACT_8BITS(p); p++;
Partial list.
-rw-r--r-- | print-babel.c | 6 | ||||
-rw-r--r-- | print-icmp6.c | 3 | ||||
-rw-r--r-- | print-krb.c | 3 | ||||
-rw-r--r-- | print-lldp.c | 3 | ||||
-rw-r--r-- | print-pgm.c | 12 | ||||
-rw-r--r-- | print-ppp.c | 6 | ||||
-rw-r--r-- | print-sl.c | 6 | ||||
-rw-r--r-- | print-tcp.c | 9 |
8 files changed, 32 insertions, 16 deletions
diff --git a/print-babel.c b/print-babel.c index ae113adb..3f5c3d16 100644 --- a/print-babel.c +++ b/print-babel.c @@ -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; diff --git a/print-icmp6.c b/print-icmp6.c index aab19971..7c168b78 100644 --- a/print-icmp6.c +++ b/print-icmp6.c @@ -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,"???")); diff --git a/print-krb.c b/print-krb.c index 3685ab6c..5dc895fd 100644 --- a/print-krb.c +++ b/print-krb.c @@ -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; diff --git a/print-lldp.c b/print-lldp.c index fd016a2e..b06dab61 100644 --- a/print-lldp.c +++ b/print-lldp.c @@ -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) { diff --git a/print-pgm.c b/print-pgm.c index e2d721c1..94f3465b 100644 --- a/print-pgm.c +++ b/print-pgm.c @@ -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)); diff --git a/print-ppp.c b/print-ppp.c index b6723f85..9ace0e23 100644 --- a/print-ppp.c +++ b/print-ppp.c @@ -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; @@ -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 *")); diff --git a/print-tcp.c b/print-tcp.c index fb7b14a4..793aec24 100644 --- a/print-tcp.c +++ b/print-tcp.c @@ -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, "]")); |