From: guy Date: Wed, 21 Jul 2004 22:00:10 +0000 (+0000) Subject: The first argument to "ascii_print_with_offset()", "ascii_print()", X-Git-Tag: tcpdump-3.9.1~300 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/03862177ea6a26f0792f47e736f2457b4fc7c898 The first argument to "ascii_print_with_offset()", "ascii_print()", "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. --- diff --git a/interface.h b/interface.h index c9aca357..9eae7a23 100644 --- a/interface.h +++ b/interface.h @@ -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 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 *); diff --git a/netdissect.h b/netdissect.h index 86621472..b479c0dd 100644 --- a/netdissect.h +++ b/netdissect.h @@ -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 *, diff --git a/print-ascii.c b/print-ascii.c index 78297c44..1b894850 100644 --- a/print-ascii.c +++ b/print-ascii.c @@ -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 #include @@ -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); } diff --git a/print-esp.c b/print-esp.c index 43bdfa79..6855a8c7 100644 --- a/print-esp.c +++ b/print-esp.c @@ -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"