diff options
author | jilles <jilles@FreeBSD.org> | 2013-09-06 21:02:06 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2013-09-06 21:02:06 +0000 |
commit | a0c0abfff1f209c44763018cdf616c7fe5f16640 (patch) | |
tree | cc3e6c5d69e4d0eee1e3bcb2c052aeb0be9035c8 /lib/libc/net/name6.c | |
parent | 015eb27a8b0450258dd29fd9db494e07060a4a45 (diff) | |
download | FreeBSD-src-a0c0abfff1f209c44763018cdf616c7fe5f16640.zip FreeBSD-src-a0c0abfff1f209c44763018cdf616c7fe5f16640.tar.gz |
libc: Use SOCK_CLOEXEC for various internal file descriptors.
This change avoids undesirably passing some internal file descriptors to a
process created (fork+exec) by another thread.
Kernel support for SOCK_CLOEXEC was added in r248534, March 19, 2013.
Diffstat (limited to 'lib/libc/net/name6.c')
-rw-r--r-- | lib/libc/net/name6.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c index 118e033..97880a2 100644 --- a/lib/libc/net/name6.c +++ b/lib/libc/net/name6.c @@ -235,7 +235,7 @@ getipnodebyname(const char *name, int af, int flags, int *errp) if (flags & AI_ADDRCONFIG) { int s; - if ((s = _socket(af, SOCK_DGRAM, 0)) < 0) + if ((s = _socket(af, SOCK_DGRAM | SOCK_CLOEXEC, 0)) < 0) return NULL; /* * TODO: @@ -868,7 +868,8 @@ set_source(struct hp_order *aio, struct policyhead *ph) } /* open a socket to get the source address for the given dst */ - if ((s = _socket(ss.ss_family, SOCK_DGRAM, IPPROTO_UDP)) < 0) + if ((s = _socket(ss.ss_family, SOCK_DGRAM | SOCK_CLOEXEC, + IPPROTO_UDP)) < 0) return; /* give up */ if (_connect(s, (struct sockaddr *)&ss, ss.ss_len) < 0) goto cleanup; |