Skip to content

Commit

Permalink
Merge pull request #202 from jasperla/openbsd_fdleak
Browse files Browse the repository at this point in the history
Plug an fd leak in the OpenBSD-specific code for _first_
  • Loading branch information
Airblader committed Feb 7, 2017
2 parents c117206 + 3c6d5ac commit 37e73e7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/first_network_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 37e73e7

Please sign in to comment.