]> The Tcpdump Group git mirrors - tcpdump/blobdiff - util.c
Don't dump core if a null "struct tok" array pointer is passed to
[tcpdump] / util.c
diff --git a/util.c b/util.c
index 97d352720e407cc1da965f16bd1c7f80a8a52761..47d7a136c462d05968e46a3167f09cb291ad5df6 100644 (file)
--- 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.94 2004-06-15 23:05:06 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/util.c,v 1.95.2.1 2005-04-25 16:15:07 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) {
-               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";
@@ -260,7 +262,7 @@ bittok2str(register const struct tok *lp, register const char *fmt,
         register int rotbit; /* this is the bit we rotate through all bitpositions */
         register int tokval;
 
-       while (lp->s != NULL) {
+       while (lp->s != NULL && lp != NULL) {
             tokval=lp->v;   /* load our first value */
             rotbit=1;
             while (rotbit != 0) {