mirror of git://git.musl-libc.org/musl
fix missing SOCK_CLOEXEC in various functions that use sockets internally
This commit is contained in:
parent
ca9aff6a16
commit
0716b10ac8
|
@ -127,7 +127,7 @@ int getifaddrs(struct ifaddrs **ifap)
|
|||
}
|
||||
if_freenameindex(ii);
|
||||
|
||||
int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
|
||||
int sock = socket(PF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_IP);
|
||||
if(sock == -1) goto err2;
|
||||
struct ifreq reqs[32]; /* arbitrary chosen boundary */
|
||||
struct ifconf conf = {.ifc_len = sizeof reqs, .ifc_req = reqs};
|
||||
|
|
|
@ -10,7 +10,7 @@ char *if_indextoname(unsigned index, char *name)
|
|||
struct ifreq ifr;
|
||||
int fd, r;
|
||||
|
||||
if ((fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) return 0;
|
||||
if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) return 0;
|
||||
ifr.ifr_ifindex = index;
|
||||
r = ioctl(fd, SIOCGIFNAME, &ifr);
|
||||
__syscall(SYS_close, fd);
|
||||
|
|
|
@ -47,7 +47,7 @@ struct if_nameindex *if_nameindex()
|
|||
{
|
||||
size_t n;
|
||||
void *p = 0;
|
||||
int s = socket(AF_UNIX, SOCK_DGRAM, 0);
|
||||
int s = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||
if (s>=0) {
|
||||
for (n=0; (p=do_nameindex(s, n)) == (void *)-1; n++);
|
||||
__syscall(SYS_close, s);
|
||||
|
|
|
@ -10,7 +10,7 @@ unsigned if_nametoindex(const char *name)
|
|||
struct ifreq ifr;
|
||||
int fd, r;
|
||||
|
||||
if ((fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) return -1;
|
||||
if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) return -1;
|
||||
strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
|
||||
r = ioctl(fd, SIOCGIFINDEX, &ifr);
|
||||
__syscall(SYS_close, fd);
|
||||
|
|
Loading…
Reference in New Issue