From cd3093bcfedcfd0742d9eccfbe484eeeb1b06f19 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 27 Nov 2017 20:39:17 +0000 Subject: [PATCH] SSH packet logs: don't rely on locale's isprint(). I've just noticed that on OS X I get high-bit-set junk in the text side of my hex/ASCII dumps. That's going to confuse all sorts of things that will interpret them in the wrong character set (indeed, in many cases there won't even be a _right_ character set). Coerce to ordinary ASCII. --- logging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logging.c b/logging.c index 865fe9b8..c3634274 100644 --- a/logging.c +++ b/logging.c @@ -351,7 +351,7 @@ void log_packet(void *handle, int direction, int type, } dumpdata[10+2+3*(p%16)] = smalldata[0]; dumpdata[10+2+3*(p%16)+1] = smalldata[1]; - dumpdata[10+1+3*16+2+(p%16)] = (isprint(c) ? c : '.'); + dumpdata[10+1+3*16+2+(p%16)] = (c >= 0x20 && c < 0x7F ? c : '.'); output_pos = (p%16) + 1; }