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 <gerald@wireshark.org>
Reviewed-by: Evan Huus <eapache@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2014-08-27 13:55:12 -07:00
parent a8523d7df4
commit 5ee328e90b
1 changed files with 6 additions and 2 deletions

View File

@ -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);