From: guy Date: Mon, 25 Apr 2005 16:14:43 +0000 (+0000) Subject: Don't dump core if a null "struct tok" array pointer is passed to X-Git-Tag: tcpdump-4.0.0~472 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/686d1b333d7f2cad7bd272dcff045885a809e54f Don't dump core if a null "struct tok" array pointer is passed to "tok2strbuf()". --- diff --git a/util.c b/util.c index 2310a7d9..a5f275e9 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.95 2005-03-21 11:35:55 hannes Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.96 2005-04-25 16:14:43 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -219,10 +219,12 @@ const char * tok2strbuf(register const struct tok *lp, register const char *fmt, register int v, char *buf, size_t bufsize) { - while (lp->s != NULL && lp != NULL) { - if (lp->v == v) - return (lp->s); - ++lp; + if (lp != NULL) { + while (lp->s != NULL) { + if (lp->v == v) + return (lp->s); + ++lp; + } } if (fmt == NULL) fmt = "#%d";