mirror of
https://github.com/fluencelabs/musl
synced 2025-06-29 14:42:01 +00:00
fix missing SOCK_CLOEXEC in various functions that use sockets internally
This commit is contained in:
@ -127,7 +127,7 @@ int getifaddrs(struct ifaddrs **ifap)
|
|||||||
}
|
}
|
||||||
if_freenameindex(ii);
|
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;
|
if(sock == -1) goto err2;
|
||||||
struct ifreq reqs[32]; /* arbitrary chosen boundary */
|
struct ifreq reqs[32]; /* arbitrary chosen boundary */
|
||||||
struct ifconf conf = {.ifc_len = sizeof reqs, .ifc_req = reqs};
|
struct ifconf conf = {.ifc_len = sizeof reqs, .ifc_req = reqs};
|
||||||
|
@ -10,7 +10,7 @@ char *if_indextoname(unsigned index, char *name)
|
|||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
int fd, r;
|
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;
|
ifr.ifr_ifindex = index;
|
||||||
r = ioctl(fd, SIOCGIFNAME, &ifr);
|
r = ioctl(fd, SIOCGIFNAME, &ifr);
|
||||||
__syscall(SYS_close, fd);
|
__syscall(SYS_close, fd);
|
||||||
|
@ -47,7 +47,7 @@ struct if_nameindex *if_nameindex()
|
|||||||
{
|
{
|
||||||
size_t n;
|
size_t n;
|
||||||
void *p = 0;
|
void *p = 0;
|
||||||
int s = socket(AF_UNIX, SOCK_DGRAM, 0);
|
int s = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0);
|
||||||
if (s>=0) {
|
if (s>=0) {
|
||||||
for (n=0; (p=do_nameindex(s, n)) == (void *)-1; n++);
|
for (n=0; (p=do_nameindex(s, n)) == (void *)-1; n++);
|
||||||
__syscall(SYS_close, s);
|
__syscall(SYS_close, s);
|
||||||
|
@ -10,7 +10,7 @@ unsigned if_nametoindex(const char *name)
|
|||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
int fd, r;
|
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);
|
strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
|
||||||
r = ioctl(fd, SIOCGIFINDEX, &ifr);
|
r = ioctl(fd, SIOCGIFINDEX, &ifr);
|
||||||
__syscall(SYS_close, fd);
|
__syscall(SYS_close, fd);
|
||||||
|
Reference in New Issue
Block a user