about summary refs log tree commit diff
path: root/resolv/res_send.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-04-19 07:45:04 +0200
committerFlorian Weimer <fweimer@redhat.com>2017-04-19 07:45:04 +0200
commit2f83a7294d0d0904d72839843a80531769525d59 (patch)
tree709774c38a94b5b99735121ce1e5979605fa0ce0 /resolv/res_send.c
parente92030239abb4038d4f915d47021d6c037239309 (diff)
downloadglibc-2f83a7294d0d0904d72839843a80531769525d59.tar.gz
glibc-2f83a7294d0d0904d72839843a80531769525d59.tar.xz
glibc-2f83a7294d0d0904d72839843a80531769525d59.zip
Create more sockets with SOCK_CLOEXEC [BZ #15722]
Diffstat (limited to 'resolv/res_send.c')
-rw-r--r--resolv/res_send.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/resolv/res_send.c b/resolv/res_send.c
index ffb9a6af7b..3de0b3e07c 100644
--- a/resolv/res_send.c
+++ b/resolv/res_send.c
@@ -692,7 +692,8 @@ send_vc(res_state statp,
 		if (statp->_vcsock >= 0)
 		  __res_iclose(statp, false);
 
-		statp->_vcsock = socket(nsap->sa_family, SOCK_STREAM, 0);
+		statp->_vcsock = socket
+		  (nsap->sa_family, SOCK_STREAM | SOCK_CLOEXEC, 0);
 		if (statp->_vcsock < 0) {
 			*terrno = errno;
 			Perror(statp, stderr, "socket(vc)", errno);
@@ -902,14 +903,16 @@ reopen (res_state statp, int *terrno, int ns)
 
 		/* only try IPv6 if IPv6 NS and if not failed before */
 		if (nsap->sa_family == AF_INET6 && !statp->ipv6_unavail) {
-			EXT(statp).nssocks[ns]
-				= socket(PF_INET6, SOCK_DGRAM|SOCK_NONBLOCK, 0);
+			EXT(statp).nssocks[ns] = socket
+			  (PF_INET6,
+			   SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
 			if (EXT(statp).nssocks[ns] < 0)
 			    statp->ipv6_unavail = errno == EAFNOSUPPORT;
 			slen = sizeof (struct sockaddr_in6);
 		} else if (nsap->sa_family == AF_INET) {
-			EXT(statp).nssocks[ns]
-				= socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, 0);
+			EXT(statp).nssocks[ns] = socket
+			  (PF_INET,
+			   SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
 			slen = sizeof (struct sockaddr_in);
 		}
 		if (EXT(statp).nssocks[ns] < 0) {