Bruno Haible wrote:
-  if (nfd < 0)
+  if (nfd > TYPE_MAXIMUM (nfds_t) / 2)

This doesn't look right. What does TYPE_MAXIMUM (nfds_t) / 2 have to do with anything? Plus, five lines later there's a comment that starts "Don't check directly for NFD too large" and this seems to directly contradict the code now. Plus, there's another "nfd < 0" in the WINDOWS_NATIVE case.

How about the attached patch?
diff --git a/lib/poll.c b/lib/poll.c
index 803ac0e..ac38658 100644
--- a/lib/poll.c
+++ b/lib/poll.c
@@ -336,11 +336,6 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
   int maxfd, rc;
   nfds_t i;
 
-  if (nfd > TYPE_MAXIMUM (nfds_t) / 2)
-    {
-      errno = EINVAL;
-      return -1;
-    }
   /* Don't check directly for NFD too large.  Any practical use of a
      too-large NFD is caught by one of the other checks below, and
      checking directly for getdtablesize is too much of a portability
@@ -434,7 +429,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
   int rc = 0;
   nfds_t i;
 
-  if (nfd < 0 || timeout < -1)
+  if (timeout < -1)
     {
       errno = EINVAL;
       return -1;

Reply via email to