X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/b5cbb4d2bbca5fda7fc3ab5996d416aaf727df30..refs/heads/master:/print-lwres.c diff --git a/print-lwres.c b/print-lwres.c index f677b971..29b49c6e 100644 --- a/print-lwres.c +++ b/print-lwres.c @@ -29,9 +29,7 @@ /* \summary: BIND9 Lightweight Resolver protocol printer */ -#ifdef HAVE_CONFIG_H #include -#endif #include "netdissect-stdinc.h" @@ -94,7 +92,7 @@ typedef struct lwres_addr lwres_addr_t; struct lwres_addr { nd_uint32_t family; nd_uint16_t length; - /* address folows */ + /* address follows */ }; #define LWRES_ADDR_LEN 6 @@ -182,7 +180,7 @@ static const struct tok opcode[] = { { LWRES_OPCODE_GETADDRSBYNAME, "getaddrsbyname", }, { LWRES_OPCODE_GETNAMEBYADDR, "getnamebyaddr", }, { LWRES_OPCODE_GETRDATABYNAME, "getrdatabyname", }, - { 0, NULL, }, + { 0, NULL, }, }; /* print-domain.c */ @@ -191,10 +189,10 @@ extern const struct tok ns_class2str[]; static unsigned lwres_printname(netdissect_options *ndo, - size_t l, const u_char *p0) + u_int l, const u_char *p0) { ND_PRINT(" "); - (void)nd_printn(ndo, p0, l, NULL); + nd_printjn(ndo, p0, l); p0 += l; if (GET_U_1(p0)) ND_PRINT(" (not NUL-terminated!)"); @@ -267,7 +265,7 @@ lwres_printaddr(netdissect_options *ndo, } } - return ND_BYTES_BETWEEN(p, p0); + return ND_BYTES_BETWEEN(p0, p); } void @@ -291,7 +289,9 @@ lwres_print(netdissect_options *ndo, if (ndo->ndo_vflag || v != LWRES_LWPACKETVERSION_0) ND_PRINT(" v%u", v); if (v != LWRES_LWPACKETVERSION_0) { - s = bp + GET_BE_U_4(np->length); + uint32_t pkt_len = GET_BE_U_4(np->length); + ND_TCHECK_LEN(bp, pkt_len); + s = bp + pkt_len; goto tail; } @@ -546,7 +546,7 @@ lwres_print(netdissect_options *ndo, ND_PRINT(" [len: %u != %u]", GET_BE_U_4(np->length), length); } - if (!unsupported && s < bp + GET_BE_U_4(np->length)) + if (!unsupported && ND_BYTES_BETWEEN(bp, s) < GET_BE_U_4(np->length)) ND_PRINT("[extra]"); return;