{
struct ifreq ifr = {};
struct ethtool_cmd ethc = {};
- int len, rc, sock;
+ int len, rc, sock = -1;
char *ifname;
must_read(&len, sizeof(int));
ethc.cmd = ETHTOOL_GSET;
if (((rc = sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) ||
(rc = ioctl(sock, SIOCETHTOOL, &ifr)) != 0) {
+ if (sock != -1) close(sock);
must_write(&rc, sizeof(int));
return;
}
+ close(sock);
must_write(&rc, sizeof(int));
must_write(ðc, sizeof(struct ethtool_cmd));
}
static void
asroot_iface_multicast()
{
- int sock, add, rc = 0;
+ int sock = -1, add, rc = 0;
struct ifreq ifr = { .ifr_name = {} };
must_read(ifr.ifr_name, IFNAMSIZ);
#if defined HOST_OS_LINUX
&ifr) < 0) && (errno != EADDRINUSE)))
rc = errno;
+ if (sock != -1) close(sock);
must_write(&rc, sizeof(rc));
}