Permalink
Browse files

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().
  • Loading branch information...
1 parent c7d94fc commit 31b92803e7c0b59ca23f1acd800e600188574662 @guyharris guyharris committed Mar 24, 2011
Showing with 3 additions and 2 deletions.
  1. +3 −2 inet.c
View
5 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.

0 comments on commit 31b9280

Please sign in to comment.