summaryrefslogtreecommitdiffstats
path: root/lib/libc/resolv
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2007-03-05 19:39:51 +0000
committerjhb <jhb@FreeBSD.org>2007-03-05 19:39:51 +0000
commit881404945f12fdcb7b017540d68b3b9ff2572d5a (patch)
tree295ef28e06f1d8aaf1e47af64e334ec9a429d4fa /lib/libc/resolv
parent7c030f485b1ce7e0d2778461dee784124861947d (diff)
downloadFreeBSD-src-881404945f12fdcb7b017540d68b3b9ff2572d5a.zip
FreeBSD-src-881404945f12fdcb7b017540d68b3b9ff2572d5a.tar.gz
Only reject file descriptors higher than FD_SETSIZE if we are not using
poll(2) or kqueue(2). Previously we rejected fd's higher than FD_SETSIZE for kevent(2), and larger than sysconf(_SC_OPEN_MAX) for poll(2). However, the check for poll(2) wasn't really needed. open(2) and socket(2) won't return an fd you can't pass to either poll(2) or kevent(2). This fixes a but where gethostbyname() would fail if you had more than 1023 files open in a process. MFC after: 1 week Reviewed by: ume Found by: ps
Diffstat (limited to 'lib/libc/resolv')
-rw-r--r--lib/libc/resolv/res_send.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/libc/resolv/res_send.c b/lib/libc/resolv/res_send.c
index b7f3f6c..455599e 100644
--- a/lib/libc/resolv/res_send.c
+++ b/lib/libc/resolv/res_send.c
@@ -124,10 +124,8 @@ __FBSDID("$FreeBSD$");
#define EXT(res) ((res)->_u._ext)
-#ifndef USE_POLL
+#if !defined(USE_POLL) && !defined(USE_KQUEUE)
static const int highestFD = FD_SETSIZE - 1;
-#else
-static int highestFD = 0;
#endif
/* Forward. */
@@ -305,10 +303,6 @@ res_nsend(res_state statp,
#endif
char abuf[NI_MAXHOST];
-#ifdef USE_POLL
- highestFD = sysconf(_SC_OPEN_MAX) - 1;
-#endif
-
/* No name servers or res_init() failure */
if (statp->nscount == 0 || EXT(statp).ext == NULL) {
errno = ESRCH;
@@ -659,10 +653,12 @@ send_vc(res_state statp,
res_nclose(statp);
statp->_vcsock = _socket(nsap->sa_family, SOCK_STREAM, 0);
+#if !defined(USE_POLL) && !defined(USE_KQUEUE)
if (statp->_vcsock > highestFD) {
res_nclose(statp);
errno = ENOTSOCK;
}
+#endif
if (statp->_vcsock < 0) {
switch (errno) {
case EPROTONOSUPPORT:
@@ -837,10 +833,12 @@ send_dg(res_state statp,
if (EXT(statp).nssocks[ns] == -1) {
EXT(statp).nssocks[ns] = _socket(nsap->sa_family,
SOCK_DGRAM, 0);
+#if !defined(USE_POLL) && !defined(USE_KQUEUE)
if (EXT(statp).nssocks[ns] > highestFD) {
res_nclose(statp);
errno = ENOTSOCK;
}
+#endif
if (EXT(statp).nssocks[ns] < 0) {
switch (errno) {
case EPROTONOSUPPORT:
OpenPOWER on IntegriCloud