summaryrefslogtreecommitdiffstats
path: root/openbsd-compat
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@dtucker.net>2022-04-01 14:38:44 +0200
committerDarren Tucker <dtucker@dtucker.net>2022-04-01 14:38:44 +0200
commit90452c8b69d065b7c7c285ff78b81418a75bcd76 (patch)
treeb9c3161b07544b0e57118e87238754e33516f22b /openbsd-compat
parentOnly run regression tests on slow VMs. (diff)
downloadopenssh-90452c8b69d065b7c7c285ff78b81418a75bcd76.tar.xz
openssh-90452c8b69d065b7c7c285ff78b81418a75bcd76.zip
Only return events from ppoll that were requested.
If the underlying system's select() returns bits that were not in the request set, our ppoll() implementation can return revents for events not requested, which can apparently cause a hang. Only return revents for activity in the requested event set. bz#3416, analysis and fix by yaroslav.kuzmin at vmssoftware com, ok djm@
Diffstat (limited to 'openbsd-compat')
-rw-r--r--openbsd-compat/bsd-poll.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/openbsd-compat/bsd-poll.c b/openbsd-compat/bsd-poll.c
index 781ee978a..9a9794f58 100644
--- a/openbsd-compat/bsd-poll.c
+++ b/openbsd-compat/bsd-poll.c
@@ -91,11 +91,11 @@ ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *tmoutp,
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))
+ if ((fds[i].events & POLLPRI) && FD_ISSET(fd, exceptfds))
fds[i].revents |= POLLPRI;
}