]> The Tcpdump Group git mirrors - libpcap/commitdiff
Correctly handle errors other than problems reading /sys/class/net.
authorGuy Harris <[email protected]>
Sun, 10 Jan 2010 19:01:56 +0000 (11:01 -0800)
committerGuy Harris <[email protected]>
Sun, 10 Jan 2010 19:01:56 +0000 (11:01 -0800)
pcap-linux.c

index f78c33d8c816de7f50729762b681286922cb62d4..9bb71d45891957a4ce66a658db9e0e0a5063b5d2 100644 (file)
@@ -1891,14 +1891,17 @@ scan_sys_class_net(pcap_if_t **devlistp, char *errbuf)
                        break;
                }
        }
-       if (errno != 0) {
+       if (ret != -1) {
                /*
-                * Error reading the directory.
+                * Well, we didn't fail for any other reason; did we
+                * fail due to an error reading the directory?
                 */
-               (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
-                   "Error reading /sys/class/net: %s",
-                   pcap_strerror(errno));
-               ret = -1;
+               if (errno != 0) {
+                       (void)snprintf(errbuf, PCAP_ERRBUF_SIZE,
+                           "Error reading /sys/class/net: %s",
+                           pcap_strerror(errno));
+                       ret = -1;
+               }
        }
 
        (void)close(fd);