]> The Tcpdump Group git mirrors - tcpdump/blobdiff - tcpdump.c
CDP: fix "Unchecked return value" found by Coverity
[tcpdump] / tcpdump.c
index de0e320e675a7486a7e85a4eb527a77eacbdc2ee..2ec7d2006b375bedf50e8ce5d7c51e33029944e6 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -43,6 +43,17 @@ The Regents of the University of California.  All rights reserved.\n";
 #include "config.h"
 #endif
 
+/*
+ * Mac OS X may ship pcap.h from libpcap 0.6 with a libpcap based on
+ * 0.8.  That means it has pcap_findalldevs() but the header doesn't
+ * define pcap_if_t, meaning that we can't actually *use* pcap_findalldevs().
+ */
+#ifdef HAVE_PCAP_FINDALLDEVS
+#ifndef HAVE_PCAP_IF_T
+#undef HAVE_PCAP_FINDALLDEVS
+#endif
+#endif
+
 #include <tcpdump-stdinc.h>
 
 #ifdef WIN32
@@ -614,12 +625,6 @@ show_devices_and_exit (void)
 #define J_FLAG
 #endif /* PCAP_ERROR_TSTAMP_TYPE_NOTSUP */
 
-#ifdef HAVE_PCAP_FINDALLDEVS
-#ifndef HAVE_PCAP_IF_T
-#undef HAVE_PCAP_FINDALLDEVS
-#endif
-#endif
-
 #ifdef HAVE_PCAP_FINDALLDEVS
 #define D_FLAG "D"
 #else
@@ -2310,7 +2315,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 +2326,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.