From abf03bc54032beeff95b1b8634cc005137e11f32 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Fri, 12 Oct 2012 15:29:16 +0000 Subject: check if the file descriptor can be stored in the select() file descriptor set (r1781 from 0.8) git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd-0.7@1782 ef36b2f9-881f-0410-afb5-c4e39611909c --- common/tio.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/common/tio.c b/common/tio.c index ce5ab61..ff75f64 100644 --- a/common/tio.c +++ b/common/tio.c @@ -184,6 +184,11 @@ static int tio_select(TFILE *fp, int readfd, const struct timeval *deadline) while (1) { /* prepare our filedescriptorset */ + if (fp->fd>=FD_SETSIZE) + { + errno=EBADFD; + return -1; + } FD_ZERO(&fdset); FD_SET(fp->fd,&fdset); /* figure out the time we need to wait */ @@ -397,6 +402,11 @@ static int tio_flush_nonblock(TFILE *fp) fd_set fdset; int rv; /* prepare our filedescriptorset */ + if (fp->fd>=FD_SETSIZE) + { + errno=EBADFD; + return -1; + } FD_ZERO(&fdset); FD_SET(fp->fd,&fdset); /* set the timeout to 0 to poll */ -- cgit v1.2.3