about summary refs log tree commit diff
path: root/resolv
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
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')
-rw-r--r--resolv/res_hconf.c2
-rw-r--r--resolv/res_send.c13
2 files changed, 9 insertions, 6 deletions
diff --git a/resolv/res_hconf.c b/resolv/res_hconf.c
index d0d116d308..8fc06e9abd 100644
--- a/resolv/res_hconf.c
+++ b/resolv/res_hconf.c
@@ -388,7 +388,7 @@ _res_hconf_reorder_addrs (struct hostent *hp)
       /* Initialize interface table.  */
 
       /* The SIOCGIFNETMASK ioctl will only work on an AF_INET socket.  */
-      sd = __socket (AF_INET, SOCK_DGRAM, 0);
+      sd = __socket (AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
       if (sd < 0)
 	return;
 
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) {