summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2019-08-07 20:02:46 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2019-08-07 20:02:46 +0000
commit42398166645c00f43738696d33277e220123323e (patch)
tree2348a5d0f63905a2fcffb04d438ae7f8d295626f
parentd69644de85148f56efeed4259a783881e2a1bddc (diff)
downloadskalibs-42398166645c00f43738696d33277e220123323e.tar.xz
iopause_select: add protection against UB in FD_SET
-rw-r--r--src/libstddjb/iopause_select.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/libstddjb/iopause_select.c b/src/libstddjb/iopause_select.c
index 8b8479b..a98767c 100644
--- a/src/libstddjb/iopause_select.c
+++ b/src/libstddjb/iopause_select.c
@@ -35,6 +35,7 @@ int iopause_select (iopause_fd *x, unsigned int len, tain_t const *deadline, tai
x[i].revents = 0 ;
if (x[i].fd >= 0)
{
+ if (x[i].fd >= FD_SETSIZE) return (errno = EMFILE, -1) ;
if (x[i].fd >= nfds) nfds = x[i].fd + 1 ;
if (x[i].events & IOPAUSE_READ) FD_SET(x[i].fd, &rfds) ;
if (x[i].events & IOPAUSE_WRITE) FD_SET(x[i].fd, &wfds) ;