aboutsummaryrefslogtreecommitdiff
path: root/pcap-dos.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-06-01 17:58:28 -0700
committerGuy Harris <guy@alum.mit.edu>2017-06-01 17:58:28 -0700
commit42c3865d71a3d3ad3fc61ee382ad3b5113d40552 (patch)
tree669532521e73c10b2f1e520bf0c1417df255e68c /pcap-dos.c
parent1a6b088a88886eac782008f37a7219a32b86da45 (diff)
Make the checks and adjustment of the snapshot length module-dependent.
Also, initialize the snapshot length to 0, meaning "not specified", so that the default snapshot length, if not specified, is also module-dependent. That way, D-Bus has a maximum and default of 128MB, as that's the maximum message size, but other capture devices have the current MAXIMUM_SNAPLEN, so we can handle full-size D-Bus messages without advertising an overly-large snapshot length for other devices, potentially causing libpcap and programs using it or reading libpcap files to allocate overly-large buffers for other capture devices.
Diffstat (limited to 'pcap-dos.c')
-rw-r--r--pcap-dos.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/pcap-dos.c b/pcap-dos.c
index 60e9d890..7bffce5a 100644
--- a/pcap-dos.c
+++ b/pcap-dos.c
@@ -174,6 +174,17 @@ static int pcap_activate_dos (pcap_t *pcap)
return (PCAP_ERROR_RFMON_NOTSUP);
}
+ /*
+ * Turn a negative snapshot value (invalid), a snapshot value of
+ * 0 (unspecified), or a value bigger than the normal maximum
+ * value, into the maximum allowed value.
+ *
+ * If some application really *needs* a bigger snapshot
+ * length, we should just increase MAXIMUM_SNAPLEN.
+ */
+ if (pcap->snapshot <= 0 || pcap->snapshot > MAXIMUM_SNAPLEN)
+ pcap->snapshot = MAXIMUM_SNAPLEN;
+
if (pcap->snapshot < ETH_MIN+8)
pcap->snapshot = ETH_MIN+8;