libc: Make resolver sockets close-on-exec (SOCK_CLOEXEC).

Although the resolver's sockets are exposed to applications via res_state,
I do not expect them to pass the sockets across execve().
This commit is contained in:
Jilles Tjoelker 2013-09-06 23:49:54 +00:00
parent ebcbd8aeff
commit d4c612c3b8

View File

@ -660,7 +660,8 @@ send_vc(res_state statp,
if (statp->_vcsock >= 0)
res_nclose(statp);
statp->_vcsock = _socket(nsap->sa_family, SOCK_STREAM, 0);
statp->_vcsock = _socket(nsap->sa_family, SOCK_STREAM |
SOCK_CLOEXEC, 0);
#if !defined(USE_POLL) && !defined(USE_KQUEUE)
if (statp->_vcsock > highestFD) {
res_nclose(statp);
@ -851,7 +852,7 @@ send_dg(res_state statp,
nsaplen = get_salen(nsap);
if (EXT(statp).nssocks[ns] == -1) {
EXT(statp).nssocks[ns] = _socket(nsap->sa_family,
SOCK_DGRAM, 0);
SOCK_DGRAM | SOCK_CLOEXEC, 0);
#if !defined(USE_POLL) && !defined(USE_KQUEUE)
if (EXT(statp).nssocks[ns] > highestFD) {
res_nclose(statp);