aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2010-01-10 11:01:56 -0800
committerGuy Harris <guy@alum.mit.edu>2010-01-10 11:01:56 -0800
commita9a939af2ad978c2d5c3726a6513d07620e0d7da (patch)
tree5f96cfb5d11477598c4c5ce61d3e3f42c0c5ead2
parent1eb25ea82a2d573e7596c936f91f73c17f5d0c5a (diff)
Correctly handle errors other than problems reading /sys/class/net.
-rw-r--r--pcap-linux.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/pcap-linux.c b/pcap-linux.c
index f78c33d..9bb71d4 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -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);