From 7867b93f9a7c76b96f1571cddc1de0811134bb81 Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Fri, 12 Oct 2012 15:25:26 +0000 Subject: 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 --- common/tio.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 */ -- cgit v1.2.3