]> 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>
Thu, 27 Apr 2023 16:23:00 +0000 (18:23 +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 a0fee03c0881bf37740c239f732cedef1c101c0e..150086f4a4229fe5e47e0f392ac95852d1645656 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  Bruno Haible  <bruno@clisp.org>
 
        ftell, ftello: Fix recognition of pipes on native Windows.
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;