From: Guy Harris Date: Sun, 18 Dec 2016 03:32:20 +0000 (-0800) Subject: Avoid getting multiple devices per USB bus. X-Git-Tag: libpcap-1.9.0-rc1~29 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/8c33e44f6377d8cc7eee12347e7ee4fcc3ed479c?hp=a15865cf96e52419260b6b40f55d787f76c1e6e0 Avoid getting multiple devices per USB bus. --- diff --git a/pcap-bpf.c b/pcap-bpf.c index 77ce2788..60086e42 100644 --- a/pcap-bpf.c +++ b/pcap-bpf.c @@ -2677,7 +2677,14 @@ finddevs_usb(pcap_if_t **alldevsp, char *errbuf) memcpy(name, usbus_prefix, USBUS_PREFIX_LEN); memcpy(name + USBUS_PREFIX_LEN, usbitem->d_name, busnumlen); *(name + USBUS_PREFIX_LEN + busnumlen) = '\0'; - if (add_dev(alldevsp, name, PCAP_IF_UP, NULL, errbuf) == NULL) { + /* + * There's an entry in this directory for every USB device, + * not for every bus; if there's more than one device on + * the bus, there'll be more than one entry for that bus, + * so we need to avoid adding multiple capture devices + * for each bus. + */ + if (find_or_add_dev(alldevsp, name, PCAP_IF_UP, NULL, errbuf) == NULL) { free(name); closedir(usbdir); return (PCAP_ERROR);