]> Savannah Git Hosting - gnulib.git/commitdiff
select, pselect: Fix test failure on native Windows.
authorBruno Haible <bruno@clisp.org>
Mon, 24 Apr 2023 19:28:32 +0000 (21:28 +0200)
committerBruno Haible <bruno@clisp.org>
Mon, 24 Apr 2023 19:33:23 +0000 (21:33 +0200)
* lib/select.c (rpl_select): Fail if nfds is out-of-range.
* lib/pselect.c (pselect): Likewise.

ChangeLog
lib/pselect.c
lib/select.c

index 8d39a640237c610ac5e355cf84216e03fbe7d4d9..587b2103230dfbd60e7f4b5216df69bcd47e9242 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-04-24  Bruno Haible  <bruno@clisp.org>
+
+       select, pselect: Fix test failure on native Windows.
+       * lib/select.c (rpl_select): Fail if nfds is out-of-range.
+       * lib/pselect.c (pselect): Likewise.
+
 2023-04-24  Paul Eggert  <eggert@cs.ucla.edu>
 
        fclose: pacify gcc -Wanalyzer-file-leak
index f5d21e1048afdfc527b69f75e2aed11177504099..52d38378783628179f74ff5a6262237531481b3d 100644 (file)
@@ -45,6 +45,12 @@ pselect (int nfds, fd_set *restrict rfds,
   sigset_t origmask;
   struct timeval tv, *tvp;
 
+  if (nfds < 0 || nfds > FD_SETSIZE)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+
   if (timeout)
     {
       if (! (0 <= timeout->tv_nsec && timeout->tv_nsec < 1000000000))
index 3d3efff3dea31310df4f0ced9176626121c90ae5..6b6ca4154c1130db6a61ef2485f4c9f9bf7c2c17 100644 (file)
@@ -279,8 +279,11 @@ rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
   int i, fd, rc;
   clock_t tend;
 
-  if (nfds > FD_SETSIZE)
-    nfds = FD_SETSIZE;
+  if (nfds < 0 || nfds > FD_SETSIZE)
+    {
+      errno = EINVAL;
+      return -1;
+    }
 
   if (!timeout)
     wait_timeout = INFINITE;