diff options
author | Guy Harris <guy@alum.mit.edu> | 2019-09-01 16:11:32 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2019-09-01 16:11:32 -0700 |
commit | 9a6a6502413e657277e74ac1d0842ddca34cab50 (patch) | |
tree | 09d3a2d474389be1d655f92a19263b713dd8677e /print-ssh.c | |
parent | 50c1904960bec90e234100a7c1b081d771c48e9b (diff) | |
download | tcpdump-9a6a6502413e657277e74ac1d0842ddca34cab50.tar.gz |
Don't use <ctype.h> macros.
Some of them are locale-dependent, and all of them run the risk of
failing if you hand them a char with the 8th bit set.
Move our replacements to a new netdissect-ctype.h file, and, for the
ones that check for particular character types, add _ASCII to the name,
to indicate that only ASCII characters pass the check. Do the same for
the ones that map between cases, to indicate that they only map ASCII
letters.
For isspace(), explicitly check for the characters we care about, to
make it clearer what we're doing.
Diffstat (limited to 'print-ssh.c')
-rw-r--r-- | print-ssh.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/print-ssh.c b/print-ssh.c index bb983355..a6c66d74 100644 --- a/print-ssh.c +++ b/print-ssh.c @@ -22,6 +22,8 @@ #include <stdio.h> #include <stdlib.h> +#include "netdissect-ctype.h" + #include "netdissect.h" #include "extract.h" @@ -44,14 +46,17 @@ ssh_print_version(netdissect_options *ndo, const u_char *pptr, u_int len) idx++; while (idx < len) { - if (GET_U_1(pptr + idx) == '\n') { + u_char c; + + c = GET_U_1(pptr + idx); + if (c == '\n') { /* * LF without CR; end of line. * Skip the LF and print the line, with the * exception of the LF. */ goto print; - } else if (GET_U_1(pptr + idx) == '\r') { + } else if (c == '\r') { /* CR - any LF? */ if ((idx+1) >= len) { /* not in this packet */ @@ -71,8 +76,7 @@ ssh_print_version(netdissect_options *ndo, const u_char *pptr, u_int len) * if it were binary data and don't print it. */ goto trunc; - } else if (!isascii(GET_U_1(pptr + idx)) || - !isprint(GET_U_1(pptr + idx)) ) { + } else if (!ND_ASCII_ISPRINT(c) ) { /* * Not a printable ASCII character; treat this * as if it were binary data and don't print it. |