]> 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:35:28 +0000 (18:35 +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 b71a7660756ab8845298998683fa9e592510916c..d94710855d23c98fed7a9685043a1cdb1df53fdf 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 a1eca0c6a2621cc7168ef1a14fda1aae84cddd9b..52d38378783628179f74ff5a6262237531481b3d 100644 (file)
@@ -1,6 +1,6 @@
 /* pselect - synchronous I/O multiplexing
 
-   Copyright 2011-2022 Free Software Foundation, Inc.
+   Copyright 2011-2023 Free Software Foundation, Inc.
 
    This file is part of gnulib.
 
@@ -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 c24249822d97591feb873e94fcb52fdeb6960b26..6b6ca4154c1130db6a61ef2485f4c9f9bf7c2c17 100644 (file)
@@ -1,7 +1,7 @@
 /* Emulation for select(2)
    Contributed by Paolo Bonzini.
 
-   Copyright 2008-2022 Free Software Foundation, Inc.
+   Copyright 2008-2023 Free Software Foundation, Inc.
 
    This file is part of gnulib.
 
@@ -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;