From: Guy Harris Date: Thu, 24 Mar 2011 16:40:46 +0000 (-0700) Subject: Don't set errbuf to an error message if pcap_findalldevs() returns 0. X-Git-Tag: libpcap-1.2.1~70 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/31b92803e7c0b59ca23f1acd800e600188574662?ds=sidebyside Don't set errbuf to an error message if pcap_findalldevs() returns 0. When we call pcap_open_live() to check whether we can open a device for capturing, to decide whether to add it to the list of devices for pcap_findalldevs(), pass it a separate error string buffer, so that, if we don't find any devices because we don't have sufficient permissions to open any of them, we don't set the errbuf argument to pcap_findalldevs(). --- diff --git a/inet.c b/inet.c index 898cb3ed..6ae46ef8 100644 --- a/inet.c +++ b/inet.c @@ -133,6 +133,7 @@ add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name, pcap_t *p; pcap_if_t *curdev, *prevdev, *nextdev; int this_instance; + char open_errbuf[PCAP_ERRBUF_SIZE]; /* * Is there already an entry in the list for this interface? @@ -192,11 +193,11 @@ add_or_find_if(pcap_if_t **curdev_ret, pcap_if_t **alldevs, const char *name, } strcpy(en_name, "en"); strcat(en_name, name + 3); - p = pcap_open_live(en_name, 68, 0, 0, errbuf); + p = pcap_open_live(en_name, 68, 0, 0, open_errbuf); free(en_name); } else #endif /* __APPLE */ - p = pcap_open_live(name, 68, 0, 0, errbuf); + p = pcap_open_live(name, 68, 0, 0, open_errbuf); if (p == NULL) { /* * No. Don't bother including it.