From: Francois-Xavier Le Bail Date: Wed, 22 Nov 2017 14:27:53 +0000 (+0100) Subject: Use more the EXTRACT_8BITS() macro to fetch a one-byte value (22/n) X-Git-Tag: tcpdump-4.99-bp~1730 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/01cd3621f1ded1d0ec5cb55a87bcc3d735d59422?ds=sidebyside Use more the EXTRACT_8BITS() macro to fetch a one-byte value (22/n) In ND_PRINT() macro calls, *p++. Partial list. --- diff --git a/print-cdp.c b/print-cdp.c index 37db394d..586a5ec8 100644 --- a/print-cdp.c +++ b/print-cdp.c @@ -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) diff --git a/print-icmp6.c b/print-icmp6.c index 4a8c9d51..bd920faf 100644 --- a/print-icmp6.c +++ b/print-icmp6.c @@ -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--; } } diff --git a/print-krb.c b/print-krb.c index 5dc895fd..ef6a83b2 100644 --- a/print-krb.c +++ b/print-krb.c @@ -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; diff --git a/print-l2tp.c b/print-l2tp.c index 6682d71a..782c0fea 100644 --- a/print-l2tp.c +++ b/print-l2tp.c @@ -268,7 +268,8 @@ print_string(netdissect_options *ndo, const u_char *dat, u_int length) { u_int i; for (i=0; i