]> The Tcpdump Group git mirrors - tcpdump/commitdiff
do not attempt to telnet option chars directly - they usually include
authoritojun <itojun>
Sun, 28 May 2000 04:23:14 +0000 (04:23 +0000)
committeritojun <itojun>
Sun, 28 May 2000 04:23:14 +0000 (04:23 +0000)
binaries like \001 or \200, and damages screen output.
improve safeputc() - print 0x80 and beyond in \xxx.

print-icmp6.c
print-telnet.c

index f8195287831eccff396e17913a2d3079c20d7d3d..0222fd59b58d33c640934c9bc1e051fc85caf7d6 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.14 2000-05-17 14:54:03 itojun Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-icmp6.c,v 1.15 2000-05-28 04:23:14 itojun Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -578,7 +578,9 @@ mld6_print(register const u_char *bp)
 #endif
 
 #ifdef HAVE_STRUCT_ICMP6_NODEINFO
-#define safeputc(c)    printf((isprint((c)) ? "%c" : "\\%03o"), c)
+#define safeputc(c) \
+    printf((((unsigned char)c) < 0x80 && isprint((c)) ? "%c" : "\\%03o"), \
+       ((unsigned char)c) & 0xff)
 
 static void
 dnsname_print(const u_char *cp, const u_char *ep)
index cdce8398c2009f86e14dac72f717c77030867bd6..ab8351f28f00ab2decf54cf55c53f86a971f4288 100644 (file)
 
 #ifndef lint
 static const char rcsid[] =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.6 2000-01-17 06:24:26 itojun Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/print-telnet.c,v 1.7 2000-05-28 04:23:14 itojun Exp $";
 #endif
 
 #include <sys/param.h>
 #include <sys/time.h>
 #include <sys/types.h>
+#include <ctype.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
@@ -78,11 +79,26 @@ static const char rcsid[] =
 #include "interface.h"
 #include "addrtoname.h"
 
-
 #ifndef TELCMD_FIRST
 # define TELCMD_FIRST SE
 #endif
 
+static void safeputs __P((const char *));
+
+#define safeputc(c) \
+    printf((((unsigned char)c) < 0x80 && isprint((c)) ? "%c" : "\\%03o"), \
+       ((unsigned char)c) & 0xff)
+
+static void
+safeputs(s)
+       const char *s;
+{
+       while (*s) {
+               safeputc(*s);
+               s++;
+       }
+}
+
 void
 telnet_print(register const u_char *sp, u_int length)
 {
@@ -174,11 +190,13 @@ telnet_print(register const u_char *sp, u_int length)
                        hex_print_with_offset(osp, i, off);
                        off += i;
                        if (i > 8)
-                               printf("\n\t\t\t\t%s", tnet);
+                               printf("\n\t\t\t\t");
                        else
-                               printf("%*s\t%s", (8 - i) * 3, "", tnet);
+                               printf("%*s\t", (8 - i) * 3, "");
+                       safeputs(tnet);
                } else {
-                       printf("%s%s", (first) ? " [telnet " : ", ", tnet);
+                       printf("%s", (first) ? " [telnet " : ", ");
+                       safeputs(tnet);
                }
                first = 0;
        }