/* \summary: Domain Name System (DNS) printer */
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include "netdissect-stdinc.h"
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:
case T_URI:
if (!ND_TTEST_LEN(cp, len))
return(NULL);
+ 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);
}
}
return (rp); /* XXX This isn't always right */
+
+trunc:
+ return(NULL);
}
void
if (arcount)
goto trunc;
}
- }
- else {
+ } else {
/* this is a request */
ND_PRINT("%u%s%s%s", GET_BE_U_2(np->id),
ns_ops[DNS_OPCODE(flags)],
ND_PRINT(" [%uq]", qdcount);
if (ancount != 1)
ND_PRINT(" [%ua]", ancount);
- }
- else {
+ } else {
if (ancount)
ND_PRINT(" [%ua]", ancount);
if (qdcount != 1)