From: guy Date: Sun, 14 Jan 2007 21:29:53 +0000 (+0000) Subject: From Kevin Steves: X-Git-Tag: tcpdump-3.9.7~41 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/faf9f4d810dfc9cd301a8bc5baf9b5ae8dc7b0c3 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) --- diff --git a/print-bootp.c b/print-bootp.c index 3a0dcdf9..db8ee7da 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.78.2.4 2007-01-14 21:23:31 guy Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/tcpdump/print-bootp.c,v 1.78.2.5 2007-01-14 21:29:53 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; }