From: Todd C. Miller Date: Sat, 2 Nov 2013 16:13:54 +0000 (-0600) Subject: Only check an fd that is >= 0. Timeout-only events may have a X-Git-Tag: SUDO_1_8_9^2~120 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0eb38a228a79d3af5398b91a22e401085b869a1c;p=sudo Only check an fd that is >= 0. Timeout-only events may have a negative fd. --- diff --git a/common/event_select.c b/common/event_select.c index fc28d56e0..3d4b3088a 100644 --- a/common/event_select.c +++ b/common/event_select.c @@ -181,16 +181,18 @@ sudo_ev_scan_impl(struct sudo_event_base *base, int flags) default: /* Activate each I/O event that fired. */ TAILQ_FOREACH(ev, &base->events, entries) { - int what = 0; - if (FD_ISSET(ev->fd, base->readfds_out)) - what |= (ev->events & SUDO_EV_READ); - if (FD_ISSET(ev->fd, base->writefds_out)) - what |= (ev->events & SUDO_EV_WRITE); - if (what != 0) { - /* Make event active. */ - ev->revents = what; - TAILQ_INSERT_TAIL(&base->active, ev, active_entries); - SET(ev->flags, SUDO_EVQ_ACTIVE); + if (ev->fd >= 0) { + int what = 0; + if (FD_ISSET(ev->fd, base->readfds_out)) + what |= (ev->events & SUDO_EV_READ); + if (FD_ISSET(ev->fd, base->writefds_out)) + what |= (ev->events & SUDO_EV_WRITE); + if (what != 0) { + /* Make event active. */ + ev->revents = what; + TAILQ_INSERT_TAIL(&base->active, ev, active_entries); + SET(ev->flags, SUDO_EVQ_ACTIVE); + } } } break;