Homepage of Arthur de Jong
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2012-10-12 17:25:26 (CEST)
committer Arthur de Jong <arthur@arthurdejong.org>2012-10-12 17:25:26 (CEST)
commit7867b93f9a7c76b96f1571cddc1de0811134bb81 (patch)
tree2fb143699fdb9966d0ae65317391dfaf8c977783
parent3226690276281644be9eb0c3163465089e05cf1e (diff)
check if the file descriptor can be stored in the select() file descriptor set
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1781 ef36b2f9-881f-0410-afb5-c4e39611909c
-rw-r--r--common/tio.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/common/tio.c b/common/tio.c
index b13ba99..75d1f64 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 */
@@ -343,6 +348,11 @@ int tio_skipall(TFILE *fp)
while (1)
{
/* prepare our file descriptor set */
+ if (fp->fd>=FD_SETSIZE)
+ {
+ errno=EBADFD;
+ return -1;
+ }
FD_ZERO(&fdset);
FD_SET(fp->fd,&fdset);
/* prepare the time to wait */
@@ -446,6 +456,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 */