]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tail,tee: avoid issues with many files on systems without poll
authorPádraig Brady <P@draigBrady.com>
Mon, 6 Mar 2023 13:01:26 +0000 (13:01 +0000)
committerPádraig Brady <P@draigBrady.com>
Mon, 6 Mar 2023 13:04:40 +0000 (13:04 +0000)
* src/iopoll.c (iopoll): Protect the call to select against
passing in a descriptor larger than FD_SETSIZE.

src/iopoll.c

index a73ce05bfc3096e207c16dd29ed0f684512da3e6..ca27595e3ad884436f686cd5c87f7d97bbecfa50 100644 (file)
@@ -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)