summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Lievisse Adriaanse <jasper@humppa.nl>2017-02-07 19:23:53 +0100
committerJasper Lievisse Adriaanse <jasper@humppa.nl>2017-02-07 19:29:01 +0100
commit3c6d5ac3d7a9f83031ae468fcc5eec6686c516de (patch)
tree7189102e471899e344f45cc5da5c63cd25f24a7e
parent93576bccc3acff95206933cc1486e0d01c15316e (diff)
Plug an fd leak in the OpenBSD-specific code for _first_
-rw-r--r--src/first_network_device.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/first_network_device.c b/src/first_network_device.c
index 4e68006..5932385 100644
--- a/src/first_network_device.c
+++ b/src/first_network_device.c
@@ -94,18 +94,21 @@ static net_type_t iface_type(const char *ifname) {
strlcpy(bssid.i_name, ifname, sizeof(bssid.i_name));
ibssid = ioctl(s, SIOCG80211BSSID, &bssid);
- if (ibssid == 0 || inwid == 0)
+ if (ibssid == 0 || inwid == 0) {
+ close(s);
return NET_TYPE_WIRELESS;
+ }
(void)memset(&ifmr, 0, sizeof(ifmr));
(void)strlcpy(ifmr.ifm_name, ifname, sizeof(ifmr.ifm_name));
- if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0)
+ if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) {
+ close(s);
return NET_TYPE_OTHER;
- else
+ } else {
+ close(s);
return NET_TYPE_ETHERNET;
-
- close(s);
+ }
#else
#error Missing implementation to determine interface type.
#endif