I've had problem replying to the list, so this is just a test. BTW. tok2str() is still vulnerable.
----- Original Message ----- From: "Gisle Vanem" <[EMAIL PROTECTED]> To: "tcpdump-workers" <[EMAIL PROTECTED]> Sent: Wednesday, March 24, 2004 9:26 PM Subject: [tcpdump-workers] tok2str() patch > tok2str() is in several files used multiple times in the same > printf() statement. This doesn't work if all values 'v' are unknown. > I suggest we allow for max 4 buffer to be returned in a round-robin > fashion. > > --- tcpdump-2004.03.24/util.c Mon Dec 29 12:07:17 2003 > +++ util.c Wed Mar 24 20:22:23 2004 > @@ -212,7 +212,9 @@ > tok2str(register const struct tok *lp, register const char *fmt, > register int v) > { > - static char buf[128]; > + static char buf[4][128]; > + static int idx = 0; > + char *ret; > > while (lp->s != NULL) { > if (lp->v == v) > @@ -221,8 +223,10 @@ > } > if (fmt == NULL) > fmt = "#%d"; > - (void)snprintf(buf, sizeof(buf), fmt, v); > - return (buf); > + ret = buf[idx]; > + (void)snprintf(ret, sizeof(buf[0]), fmt, v); > + idx = (idx+1) & 3; > + return (const char*) ret; > } > > --gv - This is the tcpdump-workers list. Visit https://lists.sandelman.ca/ to unsubscribe.