From 028aeafabe6e207579baf228391c83c201c19ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Thu, 18 May 2017 17:06:40 +0200 Subject: [PATCH] libc: only return requested events in poll() Even if the underlying select() reports events, only report those to the caller that were initially requested. --- repos/libports/src/lib/libc/poll.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/repos/libports/src/lib/libc/poll.cc b/repos/libports/src/lib/libc/poll.cc index 41effddc67..e5cf9a4824 100644 --- a/repos/libports/src/lib/libc/poll.cc +++ b/repos/libports/src/lib/libc/poll.cc @@ -89,10 +89,10 @@ poll(struct pollfd fds[], nfds_t nfds, int timeout) fds[i].revents = 0; if (fd == -1) continue; - if (FD_ISSET(fd, &readfds)) { + if ((fds[i].events & POLLIN) && FD_ISSET(fd, &readfds)) { fds[i].revents |= POLLIN; } - if (FD_ISSET(fd, &writefds)) { + if ((fds[i].events & POLLOUT) && FD_ISSET(fd, &writefds)) { fds[i].revents |= POLLOUT; } if (FD_ISSET(fd, &exceptfds)) {