]> The Tcpdump Group git mirrors - tcpdump/commitdiff
add a maxlen boundary check to safeputs, print unprintable chars as hex in safeputchar
authorhannes <hannes>
Wed, 8 Feb 2006 01:40:09 +0000 (01:40 +0000)
committerhannes <hannes>
Wed, 8 Feb 2006 01:40:09 +0000 (01:40 +0000)
interface.h
netdissect.h
util.c

index a7f4f84fa007555c3acbff93b9d8d966e470f3e9..adb53cfe76bf13e4bb615a59f8edbeebcbdac326 100644 (file)
@@ -18,7 +18,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.244.2.19 2006-02-03 08:39:32 hannes Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.244.2.20 2006-02-08 01:40:09 hannes Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -152,7 +152,7 @@ extern char *read_infile(char *);
 extern char *copy_argv(char **);
 
 extern void safeputchar(int);
-extern void safeputs(const char *);
+extern void safeputs(const char *, int);
 
 extern const char *isonsap_string(const u_char *, register u_int);
 extern const char *protoid_string(const u_char *);
index d4628c9e2e2dac9c741266245140dfd8470bf1af..a91e63092233f37f6092fffa34f7ee2e226bd683 100644 (file)
@@ -21,7 +21,7 @@
  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.16.2.3 2005-09-29 07:46:46 hannes Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.16.2.4 2006-02-08 01:40:09 hannes Exp $ (LBL)
  */
 
 #ifndef netdissect_h
@@ -231,7 +231,7 @@ extern char *copy_argv(netdissect_options *, char **);
 #endif
 
 extern void safeputchar(int);
-extern void safeputs(const char *);
+extern void safeputs(const char *, int);
 
 #if 0
 extern const char *isonsap_string(netdissect_options *, const u_char *);
diff --git a/util.c b/util.c
index 571dd530e01c00a7cb9cea3e8f3af6416d2eca44..3932ef44054cc50890fd6ad2511e75134c279e10 100644 (file)
--- a/util.c
+++ b/util.c
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.95.2.5 2005-06-16 01:19:57 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.95.2.6 2006-02-08 01:40:09 hannes Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -507,10 +507,12 @@ read_infile(char *fname)
 }
 
 void
-safeputs(const char *s)
+safeputs(const char *s, int maxlen)
 {
-       while (*s) {
+    int idx = 0;
+       while (*s && idx < maxlen) {
                safeputchar(*s);
+                idx++;
                s++;
        }
 }