]> The Tcpdump Group git mirrors - libpcap/commitdiff
Handle too-short snapshot lengths in cooked mode.
authorguy <guy>
Sat, 8 Oct 2005 11:31:16 +0000 (11:31 +0000)
committerguy <guy>
Sat, 8 Oct 2005 11:31:16 +0000 (11:31 +0000)
pcap-linux.c

index d175535495df8a16cadaec216d563aa329fd125c..d48a74f22dced9ef37060838c4c8b74df5872f69 100644 (file)
@@ -27,7 +27,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.110.2.6 2005-08-16 04:25:26 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.110.2.7 2005-10-08 11:31:16 guy Exp $ (LBL)";
 #endif
 
 /*
@@ -394,7 +394,16 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms,
                 *
                 * We can safely pass "recvfrom()" a byte count
                 * based on the snapshot length.
+                *
+                * If we're in cooked mode, make the snapshot length
+                * large enough to hold a "cooked mode" header plus
+                * 1 byte of packet data (so we don't pass a byte
+                * count of 0 to "recvfrom()").
                 */
+               if (handle->md.cooked) {
+                       if (handle->snapshot < SLL_HDR_LEN + 1)
+                               handle->snapshot = SLL_HDR_LEN + 1;
+               }
                handle->bufsize = handle->snapshot;
        }