]> The Tcpdump Group git mirrors - libpcap/commitdiff
Don't set errbuf to an error message if pcap_findalldevs() returns 0.
authorGuy Harris <[email protected]>
Thu, 24 Mar 2011 16:40:46 +0000 (09:40 -0700)
committerGuy Harris <[email protected]>
Thu, 24 Mar 2011 16:40:46 +0000 (09:40 -0700)
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().

inet.c

diff --git a/inet.c b/inet.c
index 898cb3ed302f0ab552a15b164fee50980be850fa..6ae46ef87623c343affb5cac68a2c66569e47b11 100644 (file)
--- 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.