From b697a206ff9602f883d3e9b6feaa76fbe37a6819 Mon Sep 17 00:00:00 2001 From: deraadt Date: Fri, 21 Jan 2022 00:53:40 +0000 Subject: [PATCH] When poll(2) returns -1, for some error conditions pfd[].revents is not cleared. There are subtle errors in various programs. In this particular case, the program should error out. ok djm millert --- usr.bin/ssh/ssh-keyscan.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/usr.bin/ssh/ssh-keyscan.c b/usr.bin/ssh/ssh-keyscan.c index 356467dca8a..1b75bbefc34 100644 --- a/usr.bin/ssh/ssh-keyscan.c +++ b/usr.bin/ssh/ssh-keyscan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-keyscan.c,v 1.144 2021/12/02 23:45:36 djm Exp $ */ +/* $OpenBSD: ssh-keyscan.c,v 1.145 2022/01/21 00:53:40 deraadt Exp $ */ /* * Copyright 1995, 1996 by David Mazieres . * @@ -572,9 +572,11 @@ conloop(void) else timespecclear(&seltime); - while (ppoll(read_wait, maxfd, &seltime, NULL) == -1 && - (errno == EAGAIN || errno == EINTR)) - ; + while (ppoll(read_wait, maxfd, &seltime, NULL) == -1) { + if (errno == EAGAIN || errno == EINTR) + continue; + error("poll error"); + } for (i = 0; i < maxfd; i++) { if (read_wait[i].revents & (POLLHUP|POLLERR|POLLNVAL)) -- 2.20.1