From 5ee328e90b26f82fbd00316110c5edd9a5c852e6 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Wed, 27 Aug 2014 13:55:12 -0700 Subject: Increase the error buffer size for rpcap. If the rpcap port is unreachable pcap_findalldevs_ex can write more than PCAP_ERRBUF_SIZE bytes to errbuf. E.g. if we try to capture from Google's all-eights public DNS server we get: ---- Can't get list of interfaces: Is the server properly installed on 8.8.8.8? connect() failed: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (code 1 ---- Set the buffer to PCAP_ERRBUF_SIZE*4 bytes. Hopefully that's large enough. Change-Id: I19f34cda16050c1ba8b9d7d6ed2d8e77b945a2af Ping-Bug: 3554 Ping-Bug: 6922 Ping-Bug: 7021 Reviewed-on: https://code.wireshark.org/review/3880 Petri-Dish: Gerald Combs Reviewed-by: Evan Huus Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs --- caputils/capture-pcap-util.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'caputils/capture-pcap-util.c') diff --git a/caputils/capture-pcap-util.c b/caputils/capture-pcap-util.c index 8755fcefaf..1c2cd2c36e 100644 --- a/caputils/capture-pcap-util.c +++ b/caputils/capture-pcap-util.c @@ -427,9 +427,13 @@ get_interface_list_findalldevs_ex(const char *source, GList *il = NULL; pcap_if_t *alldevs, *dev; if_info_t *if_info; - char errbuf[PCAP_ERRBUF_SIZE]; + /* + * WinPcap can overflow PCAP_ERRBUF_SIZE if the host is unreachable. + * Fudge a larger size. + */ + char errbuf[PCAP_ERRBUF_SIZE*4]; - if (pcap_findalldevs_ex((char *)source, auth, &alldevs, errbuf) == -1) { + if (pcap_findalldevs_ex((char *)source, auth, &alldevs, errbuf) == -1) { *err = CANT_GET_INTERFACE_LIST; if (err_str != NULL) *err_str = cant_get_if_list_error_message(errbuf); -- cgit v1.2.1