From ac3e9eddebf49c7ce1ab7323a9cced1ad6ac6a4b Mon Sep 17 00:00:00 2001 From: guy Date: Sun, 14 Jan 2007 21:29:22 +0000 Subject: [PATCH] From Kevin Steves: 0) use TTEST/TCHECK macros vs. snapend comparisons 1) when -vvv display PAD and END options (multiple PAD options are summarized) 2) change a trunc string from bootp to rfc1048 because I think that is what is intended (matches trunc label) --- print-bootp.c | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/print-bootp.c b/print-bootp.c index df540eab..b92a6550 100644 --- a/print-bootp.c +++ b/print-bootp.c @@ -22,7 +22,7 @@ */ #ifndef lint static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.82 2007-01-14 21:22:05 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.83 2007-01-14 21:29:22 guy Exp $ (LBL)"; #endif #ifdef HAVE_CONFIG_H @@ -374,11 +374,11 @@ rfc1048_print(register const u_char *bp) bp += sizeof(int32_t); /* Loop while we there is a tag left in the buffer */ - while (bp + 1 < snapend) { + while (TTEST2(*bp, 1)) { tag = *bp++; - if (tag == TAG_PAD) + if (tag == TAG_PAD && vflag < 3) continue; - if (tag == TAG_END) + if (tag == TAG_END && vflag < 3) return; if (tag == TAG_EXTENDED_OPTION) { TCHECK2(*(bp + 1), 2); @@ -392,17 +392,29 @@ rfc1048_print(register const u_char *bp) cp = tok2str(tag2str, "?T%u", tag); c = *cp++; - /* Get the length; check for truncation */ - if (bp + 1 >= snapend) { - fputs(tstr, stdout); - return; + if (tag == TAG_PAD || tag == TAG_END) + len = 0; + else { + /* Get the length; check for truncation */ + TCHECK2(*bp, 1); + len = *bp++; } - len = *bp++; - printf("\n\t %s Option %u, length %u: ", cp, tag, len); + printf("\n\t %s Option %u, length %u%s", cp, tag, len, + len > 0 ? ": " : ""); + + if (tag == TAG_PAD && vflag > 2) { + u_int ntag = 1; + while (TTEST2(*bp, 1) && *bp == TAG_PAD) { + bp++; + ntag++; + } + if (ntag > 1) + printf(", occurs %u", ntag); + } - if (bp + len >= snapend) { - printf("[|bootp %u]", len); + if (!TTEST2(*bp, len)) { + printf("[|rfc1048 %u]", len); return; } -- 2.39.5