X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/3824a6c0417a551961d1a1bf4f94f10eff736afc..cd6afeab95d0a1eaf9fb2f88122575bbed1fba6e:/print-domain.c diff --git a/print-domain.c b/print-domain.c index ff16d737..a50e5918 100644 --- a/print-domain.c +++ b/print-domain.c @@ -19,6 +19,10 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +#ifndef lint +static const char rcsid[] _U_ = + "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.89.2.1 2005-04-20 20:59:00 guy Exp $ (LBL)"; +#endif #ifdef HAVE_CONFIG_H #include "config.h" @@ -35,10 +39,6 @@ #include "addrtoname.h" #include "extract.h" /* must come after interface.h */ -#ifndef lint -static const char rcsid[] _U_ = - "@(#) $Header: /tcpdump/master/tcpdump/print-domain.c,v 1.87 2003-11-15 00:39:19 guy Exp $ (LBL)"; -#endif static const char *ns_ops[] = { "", " inv_q", " stat", " op3", " notify", " update", " op6", " op7", " op8", " updataA", " updateD", " updateDA", @@ -89,7 +89,6 @@ static const u_char * blabel_print(const u_char *cp) { int bitlen, slen, b; - int truncated = 0; const u_char *bitp, *lim; char tc; @@ -98,27 +97,28 @@ blabel_print(const u_char *cp) if ((bitlen = *cp) == 0) bitlen = 256; slen = (bitlen + 3) / 4; - if ((lim = cp + 1 + slen) > snapend) { - truncated = 1; - lim = snapend; - } + lim = cp + 1 + slen; /* print the bit string as a hex string */ printf("\\[x"); - for (bitp = cp + 1, b = bitlen; bitp < lim && b > 7; b -= 8, bitp++) + for (bitp = cp + 1, b = bitlen; bitp < lim && b > 7; b -= 8, bitp++) { + TCHECK(*bitp); printf("%02x", *bitp); - if (bitp == lim) - printf("..."); - else if (b > 4) { + } + if (b > 4) { + TCHECK(*bitp); tc = *bitp++; printf("%02x", tc & (0xff << (8 - b))); } else if (b > 0) { + TCHECK(*bitp); tc = *bitp++; printf("%1x", ((tc >> 4) & 0x0f) & (0x0f << (4 - b))); } printf("/%d]", bitlen); - - return(truncated ? NULL : lim); + return lim; +trunc: + printf(".../%d]", bitlen); + return NULL; } static int @@ -131,9 +131,10 @@ labellen(const u_char *cp) i = *cp; if ((i & INDIR_MASK) == EDNS0_MASK) { int bitlen, elt; - - if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL) + if ((elt = (i & ~INDIR_MASK)) != EDNS0_ELT_BITLABEL) { + printf("", elt); return(-1); + } if (!TTEST2(*(cp + 1), 1)) return(-1); if ((bitlen = *(cp + 1)) == 0)