]> The Tcpdump Group git mirrors - tcpdump/commitdiff
The first argument to "ascii_print_with_offset()", "ascii_print()",
authorguy <guy>
Wed, 21 Jul 2004 22:00:10 +0000 (22:00 +0000)
committerguy <guy>
Wed, 21 Jul 2004 22:00:10 +0000 (22:00 +0000)
"hex_print_with_offset()", and "hex_print()" is a string used as a tag;
make it a "const char *", not a "const u_char *".

Copy the declaration of "strsep()" from "interface.h" to "netdissect.h",
and get rid of the include of "interface.h" from "print-esp.c", as it
includes "netdissect.h".

Update the "ND_TTEST2()" macro to do the same overflow checks that
"TTEST2()" now does.

interface.h
netdissect.h
print-ascii.c
print-esp.c

index c9aca357941fa16f71fc2e46b190ab1970500b5b..9eae7a23c1050ac225da8db45fb03af8945a1869 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.231 2004-06-06 19:20:05 hannes Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.232 2004-07-21 22:00:10 guy Exp $ (LBL)
  */
 
 #ifndef tcpdump_interface_h
@@ -161,11 +161,11 @@ extern const char *dnnum_string(u_short);
 #include <pcap.h>
 
 extern int print_unknown_data(const u_char *, const char *,int);
-extern void ascii_print_with_offset(const u_char *, const u_char *, u_int, u_int);
-extern void ascii_print(const u_char *, const u_char *, u_int);
-extern void hex_print_with_offset(const u_char *, const u_char *, u_int, u_int);
+extern void ascii_print_with_offset(const char *, const u_char *, u_int, u_int);
+extern void ascii_print(const char *, const u_char *, u_int);
+extern void hex_print_with_offset(const char *, const u_char *, u_int, u_int);
 extern void telnet_print(const u_char *, u_int);
-extern void hex_print(const u_char *, const u_char *, u_int);
+extern void hex_print(const char *, const u_char *, u_int);
 extern int ether_encap_print(u_short, const u_char *, u_int, u_int, u_short *);
 extern int llc_print(const u_char *, u_int, u_int, const u_char *,
        const u_char *, u_short *);
index 866214725d5ec87b3f9efc32ef5c0907134bdfce..b479c0dd96383571da887c664c6b7d9373ce2660 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.9 2004-07-16 14:06:00 hannes Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/netdissect.h,v 1.10 2004-07-21 22:00:10 guy Exp $ (LBL)
  */
 
 #ifndef netdissect_h
@@ -62,6 +62,10 @@ extern size_t strlcpy (char *, const char *, size_t);
 extern char *strdup (const char *str);
 #endif
 
+#ifndef HAVE_STRSEP
+extern char *strsep(char **, const char *);
+#endif
+
 struct tok {
        int v;                  /* value */
        const char *s;          /* string */
@@ -189,8 +193,16 @@ struct netdissect_options {
 #define HTONS(x)       (x) = htons(x)
 #endif
 
-/* True if  "l" bytes of "var" were captured */
-#define ND_TTEST2(var, l) ((u_char *)&(var) <= ndo->ndo_snapend - (l))
+/*
+ * True if "l" bytes of "var" were captured.
+ *
+ * The "ndo->ndo_snapend - (l) <= ndo->ndo_snapend" checks to make sure
+ * "l" isn't so large that "ndo->ndo_snapend - (l)" underflows.
+ *
+ * The check is for <= rather than < because "l" might be 0.
+ */
+#define ND_TTEST2(var, l) (ndo->ndo_snapend - (l) <= ndo->ndo_snapend && \
+                       (const u_char *)&(var) <= ndo->ndo_snapend - (l))
 
 /* True if "var" was captured */
 #define ND_TTEST(var) ND_TTEST2(var, sizeof(var))
@@ -244,13 +256,13 @@ extern int esp_print(netdissect_options *,
 extern void arp_print(netdissect_options *,const u_char *, u_int, u_int);
 
 #if 0
-extern void ascii_print_with_offset(netdissect_options *, const u_char *,
+extern void ascii_print_with_offset(netdissect_options *, const char *,
                                    u_int, u_int);    
-extern void ascii_print(netdissect_options *,const u_char *, u_int);    
-extern void hex_print_with_offset(netdissect_options *,const u_char *,
+extern void ascii_print(netdissect_options *,const char *, u_int);    
+extern void hex_print_with_offset(netdissect_options *,const char *,
                                  u_int, u_int);    
 extern void telnet_print(netdissect_options *,const u_char *, u_int);    
-extern void hex_print(netdissect_options *,const u_char *, u_int);    
+extern void hex_print(netdissect_options *,const char *, u_int);    
 extern int ether_encap_print(netdissect_options *,u_short, const u_char *,
                             u_int, u_int, u_short *);
 extern int llc_print(netdissect_options *,
index 78297c44605e367e835c8c294d6d8ff96606e5a3..1b8948501338c7af78a1f96de52c0de3cda8c284 100644 (file)
@@ -42,7 +42,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-     "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.15 2003-12-29 11:05:10 hannes Exp $";
+     "@(#) $Header: /tcpdump/master/tcpdump/print-ascii.c,v 1.16 2004-07-21 22:00:10 guy Exp $";
 #endif
 #include <tcpdump-stdinc.h>
 #include <stdio.h>
@@ -57,7 +57,7 @@ static const char rcsid[] _U_ =
                (HEXDUMP_HEXSTUFF_PER_SHORT * HEXDUMP_SHORTS_PER_LINE)
 
 void
-ascii_print_with_offset(register const u_char *ident, register const u_char *cp, register u_int length,
+ascii_print_with_offset(register const char *ident, register const u_char *cp, register u_int length,
                        register u_int oset)
 {
        register u_int i;
@@ -126,7 +126,7 @@ ascii_print_with_offset(register const u_char *ident, register const u_char *cp,
 }
 
 void
-ascii_print(register const u_char *ident, register const u_char *cp, register u_int length)
+ascii_print(register const char *ident, register const u_char *cp, register u_int length)
 {
        ascii_print_with_offset(ident, cp, length, 0);
 }
@@ -135,7 +135,7 @@ ascii_print(register const u_char *ident, register const u_char *cp, register u_
  * telnet_print() wants this.  It is essentially default_print_unaligned()
  */
 void
-hex_print_with_offset(register const u_char *ident, register const u_char *cp, register u_int length,
+hex_print_with_offset(register const char *ident, register const u_char *cp, register u_int length,
                      register u_int oset)
 {
        register u_int i, s;
@@ -162,7 +162,7 @@ hex_print_with_offset(register const u_char *ident, register const u_char *cp, r
  * just for completeness
  */
 void
-hex_print(register const u_char *ident, register const u_char *cp, register u_int length)
+hex_print(register const char *ident, register const u_char *cp, register u_int length)
 {
        hex_print_with_offset(ident, cp, length, 0);
 }
index 43bdfa794ce7f25ff830d5b83dd452a68ff456ca..6855a8c7d8bf3883172bdc3f14ab38a41feb02c9 100644 (file)
@@ -23,7 +23,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.54 2004-07-21 21:42:32 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-esp.c,v 1.55 2004-07-21 22:00:11 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -50,7 +50,6 @@ static const char rcsid[] _U_ =
 #include "ip6.h"
 #endif
 
-#include "interface.h"
 #include "netdissect.h"
 #include "addrtoname.h"
 #include "extract.h"