From: guy Date: Sat, 8 Oct 2005 11:31:16 +0000 (+0000) Subject: Handle too-short snapshot lengths in cooked mode. X-Git-Tag: libpcap-0.9.5~35 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/16ff5eeb123efd3a196295f5e297af2faeda49c9 Handle too-short snapshot lengths in cooked mode. --- diff --git a/pcap-linux.c b/pcap-linux.c index d1755354..d48a74f2 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -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; }