X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/bae81fc719586ad67dae531d7465aed380d4538d..617f68b27238e29c391700fbd935b8e48eb263df:/util.c diff --git a/util.c b/util.c index bee808c2..5746b094 100644 --- 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.105 2006-01-22 19:06:37 gianluca Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.107 2006-02-08 16:18:56 hannes Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -526,10 +526,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++; } } @@ -543,5 +545,5 @@ safeputchar(int c) if (ch < 0x80 && isprint(ch)) printf("%c", ch); else - printf("\\%03o", ch); + printf("\\0x%02x", ch); }