diff options
author | Guy Harris <guy@alum.mit.edu> | 2017-06-01 17:58:28 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2017-06-01 17:58:28 -0700 |
commit | 42c3865d71a3d3ad3fc61ee382ad3b5113d40552 (patch) | |
tree | 669532521e73c10b2f1e520bf0c1417df255e68c /pcap-dbus.c | |
parent | 1a6b088a88886eac782008f37a7219a32b86da45 (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-dbus.c')
-rw-r--r-- | pcap-dbus.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pcap-dbus.c b/pcap-dbus.c index ea3a390f..2fedaeff 100644 --- a/pcap-dbus.c +++ b/pcap-dbus.c @@ -223,6 +223,14 @@ dbus_activate(pcap_t *handle) 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 message length for D-Bus (128MB). + */ + if (handle->snapshot <= 0 || handle->snapshot > 134217728) + handle->snapshot = 134217728; + /* dbus_connection_set_max_message_size(handlep->conn, handle->snapshot); */ if (handle->opt.buffer_size != 0) dbus_connection_set_max_received_size(handlep->conn, handle->opt.buffer_size); |