X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/93b107bb867df020b059eff1d3ce3c2fa3f6196a..0023eaa78f123676bfa9c5fba72ea4b8a59aaa70:/print-domain.c?ds=sidebyside diff --git a/print-domain.c b/print-domain.c index d93aee73..08d8460a 100644 --- a/print-domain.c +++ b/print-domain.c @@ -21,9 +21,7 @@ /* \summary: Domain Name System (DNS) printer */ -#ifdef HAVE_CONFIG_H #include -#endif #include "netdissect-stdinc.h" @@ -724,11 +722,10 @@ ns_rprint(netdissect_options *ndo, len = GET_BE_U_2(cp); cp += 2; - rp = cp + len; - ND_PRINT(" %s", tok2str(ns_type2str, "Type%u", typ)); - if (rp > ndo->ndo_snapend) - return(NULL); + + ND_TCHECK_LEN(cp, len); + rp = cp + len; switch (typ) { case T_A: @@ -839,7 +836,10 @@ ns_rprint(netdissect_options *ndo, case T_URI: if (!ND_TTEST_LEN(cp, len)) return(NULL); - ND_ICHECK_U(len, <, 4); + if (len < 4) { + ND_PRINT(" len %u is too short (< 4)", len); + break; + } ND_PRINT(" %u %u ", GET_BE_U_2(cp), GET_BE_U_2(cp + 2)); if (nd_printn(ndo, cp + 4, len - 4, ndo->ndo_snapend)) return(NULL); @@ -895,8 +895,9 @@ ns_rprint(netdissect_options *ndo, } } return (rp); /* XXX This isn't always right */ -invalid: - nd_print_invalid(ndo); + +trunc: + return(NULL); } void