]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-lwres.c
Update the GitHub issue template
[tcpdump] / print-lwres.c
index f6ed8f3cfd878dc1406556932910747216fd0fa6..29b49c6e7be843c24866b1a5ae6ccb9a1859ec21 100644 (file)
@@ -29,9 +29,7 @@
 
 /* \summary: BIND9 Lightweight Resolver protocol printer */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 
@@ -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 && ND_BYTES_BETWEEN(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;