From e30af1e5840fdcabe3856f9ffcd6354b94d0a7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Mon, 6 Mar 2023 13:01:26 +0000 Subject: tail,tee: avoid issues with many files on systems without poll * src/iopoll.c (iopoll): Protect the call to select against passing in a descriptor larger than FD_SETSIZE. --- src/iopoll.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/iopoll.c b/src/iopoll.c index a73ce05bf..ca27595e3 100644 --- a/src/iopoll.c +++ b/src/iopoll.c @@ -86,6 +86,12 @@ iopoll (int fdin, int fdout, bool block) int nfds = (fdin > fdout ? fdin : fdout) + 1; int ret = 0; + if (FD_SETSIZE < nfds) + { + errno = EINVAL; + ret = -1; + } + /* If fdout has an error condition (like a broken pipe) it will be seen as ready for reading. Assumes fdout is not actually readable. */ while (0 <= ret || errno == EINTR) -- cgit v1.2.1