Fix a couple file descriptor leaks.

This commit is contained in:
Justin Maggard
2014-01-16 13:11:54 -08:00
parent 2aedabb52c
commit a21bbe557d
2 changed files with 5 additions and 4 deletions

View File

@ -202,11 +202,10 @@ getsyshwaddr(char *buf, int len)
if (fd < 0)
continue;
strncpy(ifr.ifr_name, p->ifa_name, IFNAMSIZ);
if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0)
{
close(fd);
ret = ioctl(fd, SIOCGIFHWADDR, &ifr);
close(fd);
if (ret < 0)
continue;
}
memcpy(mac, ifr.ifr_hwaddr.sa_data, 6);
#else
struct sockaddr_dl *sdl;