summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2023-03-06 13:01:26 +0000
committerPádraig Brady <P@draigBrady.com>2023-03-06 13:04:40 +0000
commite30af1e5840fdcabe3856f9ffcd6354b94d0a7ee (patch)
tree22313fe003398ec1ecaa0f3472f3c74d90937435
parent110bcd28386b1f47a4cd876098acb708fdcbbb25 (diff)
downloadcoreutils-e30af1e5840fdcabe3856f9ffcd6354b94d0a7ee.tar.gz
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.
-rw-r--r--src/iopoll.c6
1 files changed, 6 insertions, 0 deletions
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)