]> Savannah Git Hosting - gnulib.git/commitdiff
poll: Enable argument check.
authorBruno Haible <bruno@clisp.org>
Sat, 22 Apr 2017 12:18:45 +0000 (14:18 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 22 Apr 2017 12:18:45 +0000 (14:18 +0200)
* lib/poll.c: Include intprops.h.
(poll): Check value of nfd correctly.
* modules/poll (Depends-on): Add intprops.

ChangeLog
lib/poll.c
modules/poll

index 4f11fca06d790b0b8fc9e6e6c9f808f41c239a00..45a7d874e48b392df8dfea77c8446c3fdeddfda5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2017-04-22  Bruno Haible  <bruno@clisp.org>
+
+       poll: Enable argument check.
+       * lib/poll.c: Include intprops.h.
+       (poll): Check value of nfd correctly.
+       * modules/poll (Depends-on): Add intprops.
+
 2017-04-22  Bruno Haible  <bruno@clisp.org>
 
        get-rusage-data: Avoid warnings on Mac OS X.
index 88d9292d5d8735c63b31df93d6cd1a73ff6d7305..803ac0e171bcd997a9254deab84abec7c61cb11f 100644 (file)
@@ -60,6 +60,7 @@
 #include <time.h>
 
 #include "assure.h"
+#include "intprops.h"
 
 #ifndef INFTIM
 # define INFTIM (-1)
@@ -335,7 +336,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout)
   int maxfd, rc;
   nfds_t i;
 
-  if (nfd < 0)
+  if (nfd > TYPE_MAXIMUM (nfds_t) / 2)
     {
       errno = EINVAL;
       return -1;
index 57f0631e723fbd3ccc9791a5f04a84dbf39c3498..a7d117f532fe608c90b53ac200320740b39b3551 100644 (file)
@@ -9,6 +9,7 @@ Depends-on:
 poll-h
 alloca          [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
 assure          [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
+intprops        [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
 select          [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
 sockets         [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
 sys_select      [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]