commit 42398166645c00f43738696d33277e220123323e
parent d69644de85148f56efeed4259a783881e2a1bddc
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Wed, 7 Aug 2019 20:02:46 +0000
iopause_select: add protection against UB in FD_SET
Diffstat:
1 file changed, 1 insertion(+), 0 deletions(-)
diff --git 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) ;