diff options
author | Guy Harris <guy@alum.mit.edu> | 2019-04-18 10:13:49 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2019-04-18 10:13:49 -0700 |
commit | 07a7f33ba3ff346b9ce31772645a06980baca907 (patch) | |
tree | 111a5a89cefb1c27e83b1aa4fb7a95e7c6163b8d /print-ascii.c | |
parent | 7c30120f52c22c1dd971431383ad2df8ca1a12c4 (diff) | |
download | tcpdump-07a7f33ba3ff346b9ce31772645a06980baca907.tar.gz |
Fix some narrowing warnings on LP64/LLP64 platforms.
Add a ND_BYTES_AVAILABLE_AFTER() macro to find the number of bytes
available in the captured data, starting at the byte pointed to by the
argument. It returns a u_int rather than a ptrdiff_t, so it'll be
32 bits on LP64 and LLP64 platforms as well as on ILP32 platforms. Use
that macro.
Make size-of-buffer arguments size_t.
Cast some size_t and ptrdiff_t values to u_int or int.
Diffstat (limited to 'print-ascii.c')
-rw-r--r-- | print-ascii.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/print-ascii.c b/print-ascii.c index 8460f84b..63f15f0f 100644 --- a/print-ascii.c +++ b/print-ascii.c @@ -65,7 +65,7 @@ ascii_print(netdissect_options *ndo, u_char s; ndo->ndo_protocol = "ascii"; - caplength = (ndo->ndo_snapend > cp) ? ndo->ndo_snapend - cp : 0; + caplength = (ndo->ndo_snapend > cp) ? ND_BYTES_AVAILABLE_AFTER(cp) : 0; if (length > caplength) length = caplength; ND_PRINT("\n"); @@ -106,7 +106,7 @@ hex_and_ascii_print_with_offset(netdissect_options *ndo, const char *ident, char hexstuff[HEXDUMP_SHORTS_PER_LINE*HEXDUMP_HEXSTUFF_PER_SHORT+1], *hsp; char asciistuff[ASCII_LINELENGTH+1], *asp; - caplength = (ndo->ndo_snapend > cp) ? ndo->ndo_snapend - cp : 0; + caplength = (ndo->ndo_snapend > cp) ? ND_BYTES_AVAILABLE_AFTER(cp) : 0; if (length > caplength) length = caplength; nshorts = length / sizeof(u_short); @@ -169,7 +169,7 @@ hex_print_with_offset(netdissect_options *ndo, u_int i, s; u_int nshorts; - caplength = (ndo->ndo_snapend > cp) ? ndo->ndo_snapend - cp : 0; + caplength = (ndo->ndo_snapend > cp) ? ND_BYTES_AVAILABLE_AFTER(cp) : 0; if (length > caplength) length = caplength; nshorts = length / sizeof(u_short); |