]> The Tcpdump Group git mirrors - tcpdump/commitdiff
In "safeputchar()", use the result of extracting an unsigned character
authorguy <guy>
Tue, 16 Jul 2002 03:58:16 +0000 (03:58 +0000)
committerguy <guy>
Tue, 16 Jul 2002 03:58:16 +0000 (03:58 +0000)
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()").

util.c

diff --git a/util.c b/util.c
index c45277e81820726132aedb1028ed996a513cdd7a..1e451fea3c0fda01f7f804dedab2ebd513a475c4 100644 (file)
--- 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);
 }