From: guy Date: Tue, 16 Jul 2002 03:58:16 +0000 (+0000) Subject: In "safeputchar()", use the result of extracting an unsigned character X-Git-Tag: tcpdump-3.8-bp~434 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/dfa8cbe527ad9095726bff83494ac5fac347cb3b?ds=inline In "safeputchar()", use the result of extracting an unsigned character from the argument, rather than the argument itself, when testing whether it should be printed or not (the argument might well be a sign-extended version of an 8-bit character, in which case it's < 0x80 as it's negative, but it can't be safely handed to "isprint()"). --- diff --git a/util.c b/util.c index c45277e8..1e451fea 100644 --- a/util.c +++ b/util.c @@ -21,7 +21,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.73 2002-06-11 17:09:01 itojun Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.74 2002-07-16 03:58:16 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -354,8 +354,8 @@ safeputchar(int c) unsigned char ch; ch = (unsigned char)(c & 0xff); - if (c < 0x80 && isprint(c)) - printf("%c", c & 0xff); + if (ch < 0x80 && isprint(ch)) + printf("%c", ch & 0xff); else - printf("\\%03o", c & 0xff); + printf("\\%03o", ch & 0xff); }