]> The Tcpdump Group git mirrors - tcpdump/blobdiff - tcpdump.c
Don't run past the snapshot length when doing hex/ASCII dumps.
[tcpdump] / tcpdump.c
index de0e320e675a7486a7e85a4eb527a77eacbdc2ee..06ee90c633c4ed974ed6814a471acc30f7e7a82e 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -2310,7 +2310,8 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
        /*
         * Some printers want to check that they're not walking off the
         * end of the packet.
-        * Rather than pass it all the way down, we set this global.
+        * Rather than pass it all the way down, we set this member
+        * of the netdissect_options structure.
         */
        ndo->ndo_snapend = sp + h->caplen;
 
@@ -2320,6 +2321,11 @@ print_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
                 hdrlen = (*print_info->p.printer)(h, sp);
         }
 
+       /*
+        * Restore the original snapend, as a printer might have
+        * changed it.
+        */
+       ndo->ndo_snapend = sp + h->caplen;
        if (ndo->ndo_Xflag) {
                /*
                 * Print the raw packet data in hex and ASCII.