* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.249 2005-05-03 20:35:41 hannes Exp $ (LBL)
+ * @(#) $Header: /tcpdump/master/tcpdump/interface.h,v 1.250 2005-05-06 07:56:51 guy Exp $ (LBL)
*/
#ifndef tcpdump_interface_h
extern int fn_print(const u_char *, const u_char *);
extern int fn_printn(const u_char *, u_int, const u_char *);
+extern int fn_printzp(const u_char *, u_int, const u_char *);
extern int mask2plen(u_int32_t);
extern const char *tok2strary_internal(const char **, int, const char *, int);
#define tok2strary(a,f,i) tok2strary_internal(a, sizeof(a)/sizeof(a[0]),f,i)
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.9 2003-11-16 09:36:22 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-hsrp.c,v 1.10 2005-05-06 07:56:52 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
relts_print(hp->hsrp_holdtime);
printf(" priority=%d", hp->hsrp_priority);
printf(" auth=\"");
- fn_printn(hp->hsrp_authdata, sizeof(hp->hsrp_authdata), NULL);
+ if (fn_printn(hp->hsrp_authdata, sizeof(hp->hsrp_authdata),
+ snapend)) {
+ printf("\"");
+ goto trunc;
+ }
printf("\"");
}
return;
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.40 2004-05-26 19:57:57 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ipx.c,v 1.41 2005-05-06 07:56:52 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
for (i = 0; i < 8 && length > 0; i++) {
TCHECK2(ipx[25], 10);
(void)printf(" %s '", ipxsap_string(htons(EXTRACT_16BITS(&ipx[0]))));
- fn_print((u_char *)&ipx[1], (u_char *)&ipx[1] + 48);
+ if (fn_printzp((u_char *)&ipx[1], 48, snapend)) {
+ printf("'");
+ goto trunc;
+ }
printf("' addr %s",
ipxaddr_string(EXTRACT_32BITS(&ipx[25]), (u_char *)&ipx[27]));
ipx += 32;
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.107 2005-04-20 21:52:53 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-nfs.c,v 1.108 2005-05-06 07:56:52 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
cp = (u_char *)dp;
/* Update 32-bit pointer (NFS filenames padded to 32-bit boundaries) */
dp += ((len + 3) & ~3) / sizeof(*dp);
- /* XXX seems like we should be checking the length */
putchar('"');
- (void) fn_printn(cp, len, NULL);
+ if (fn_printn(cp, len, snapend)) {
+ putchar('"');
+ goto trunc;
+ }
putchar('"');
return (dp);
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.41 2004-01-28 14:54:50 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ntp.c,v 1.42 2005-05-06 07:56:53 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
break;
case PRIM_REF:
- fn_printn((u_char *)&(bp->refid), 4, NULL);
+ if (fn_printn((u_char *)&(bp->refid), 4, snapend))
+ goto trunc;
break;
case INFO_QUERY:
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.57 2005-04-20 21:55:14 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-ospf.c,v 1.58 2005-05-06 07:56:53 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
break;
case OSPF_AUTH_SIMPLE:
- (void)fn_printn(op->ospf_authdata,
- sizeof(op->ospf_authdata), NULL);
+ if (fn_printn(op->ospf_authdata,
+ sizeof(op->ospf_authdata), snapend)) {
+ printf("\"");
+ goto trunc;
+ }
printf("\"");
break;
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.63 2005-04-18 00:07:31 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-snmp.c,v 1.64 2005-05-06 07:56:53 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
p = elem->data.str;
if (printable) {
putchar('"');
- (void)fn_print(p, p + asnlen);
+ if (fn_printn(p, asnlen, snapend)) {
+ putchar('"');
+ goto trunc;
+ }
putchar('"');
} else
for (i = asnlen; i-- > 0; p++) {
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/print-vrrp.c,v 1.9 2003-11-16 09:36:41 guy Exp $";
+ "@(#) $Header: /tcpdump/master/tcpdump/print-vrrp.c,v 1.10 2005-05-06 07:56:54 guy Exp $";
#endif
#ifdef HAVE_CONFIG_H
if (auth_type == VRRP_AUTH_SIMPLE) { /* simple text password */
TCHECK(bp[7]);
printf(" auth \"");
- fn_printn(bp, 8, NULL);
+ if (fn_printn(bp, 8, snapend)) {
+ printf("\"");
+ goto trunc;
+ }
printf("\"");
}
}
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.97 2005-04-26 03:43:27 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.98 2005-05-06 07:56:54 guy Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
#include "interface.h"
/*
- * Print out a filename (or other ascii string).
+ * Print out a null-terminated filename (or other ascii string).
* If ep is NULL, assume no truncation check is needed.
* Return true if truncated.
*/
return (n == 0) ? 0 : 1;
}
+/*
+ * Print out a null-padded filename (or other ascii string).
+ * If ep is NULL, assume no truncation check is needed.
+ * Return true if truncated.
+ */
+int
+fn_printzp(register const u_char *s, register u_int n,
+ register const u_char *ep)
+{
+ register int ret;
+ register u_char c;
+
+ ret = 1; /* assume truncated */
+ while (n > 0 && (ep == NULL || s < ep)) {
+ n--;
+ c = *s++;
+ if (c == '\0') {
+ ret = 0;
+ break;
+ }
+ if (!isascii(c)) {
+ c = toascii(c);
+ putchar('M');
+ putchar('-');
+ }
+ if (!isprint(c)) {
+ c ^= 0x40; /* DEL to ?, others to alpha */
+ putchar('^');
+ }
+ putchar(c);
+ }
+ return (n == 0) ? 0 : 1;
+}
+
/*
* Print the timestamp
*/