aboutsummaryrefslogtreecommitdiff
path: root/pcap-dag.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-dag.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-dag.c')
-rw-r--r--pcap-dag.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/pcap-dag.c b/pcap-dag.c
index 80ed01a2..3f68cd6c 100644
--- a/pcap-dag.c
+++ b/pcap-dag.c
@@ -793,6 +793,17 @@ static int dag_activate(pcap_t* handle)
goto faildetach;
}
+ /*
+ * 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 (p->snapshot <= 0 || p->snapshot > MAXIMUM_SNAPLEN)
+ p->snapshot = MAXIMUM_SNAPLEN;
+
if (handle->opt.immediate) {
/* Call callback immediately.
* XXX - is this the right way to handle this?