From 701114aa6a4c403cf99775b1a66df42699af8f42 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 23 Apr 2017 03:25:10 +0200 Subject: [PATCH] poll: Enable argument check also in the Windows implementation. * lib/poll.c (poll) [WINDOWS_NATIVE]: Check value of nfd correctly. Reported by Paul Eggert. --- ChangeLog | 6 ++++++ lib/poll.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 25fe006255..b365e9e2ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2017-04-22 Bruno Haible + + poll: Enable argument check also in the Windows implementation. + * lib/poll.c (poll) [WINDOWS_NATIVE]: Check value of nfd correctly. + Reported by Paul Eggert. + 2017-04-22 Bruno Haible getlogin_r: Work around bug in Mac OS X 10.12. diff --git a/lib/poll.c b/lib/poll.c index 803ac0e171..69b3672f75 100644 --- a/lib/poll.c +++ b/lib/poll.c @@ -434,7 +434,7 @@ poll (struct pollfd *pfd, nfds_t nfd, int timeout) int rc = 0; nfds_t i; - if (nfd < 0 || timeout < -1) + if (nfd > TYPE_MAXIMUM (nfds_t) / 2 || timeout < -1) { errno = EINVAL; return -1; -- 2.39.5