From: Todd C. Miller Date: Mon, 6 Jan 2014 18:20:38 +0000 (-0700) Subject: Fix infinite loop that could be triggered by sudo_ev_loopbreak() X-Git-Tag: SUDO_1_8_9p1^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a6d211d67c17d053af5b125571a31d14834cad0;p=sudo Fix infinite loop that could be triggered by sudo_ev_loopbreak() and sudo_ev_loopcontinue(). --- diff --git a/common/event.c b/common/event.c index a7bdf7e6b..8c398cf65 100644 --- a/common/event.c +++ b/common/event.c @@ -309,16 +309,20 @@ rescan: if (ISSET(base->flags, SUDO_EVBASE_LOOPBREAK)) { /* Stop processing events immediately. */ SET(base->flags, SUDO_EVBASE_GOT_BREAK); - while ((ev = TAILQ_FIRST(&base->active)) != NULL) + while ((ev = TAILQ_FIRST(&base->active)) != NULL) { CLR(ev->flags, SUDO_EVQ_ACTIVE); + TAILQ_REMOVE(&base->active, ev, active_entries); + } goto done; } if (ISSET(base->flags, SUDO_EVBASE_LOOPCONT)) { /* Rescan events and start polling again. */ CLR(base->flags, SUDO_EVBASE_LOOPCONT); if (!ISSET(flags, SUDO_EVLOOP_ONCE)) { - while ((ev = TAILQ_FIRST(&base->active)) != NULL) + while ((ev = TAILQ_FIRST(&base->active)) != NULL) { CLR(ev->flags, SUDO_EVQ_ACTIVE); + TAILQ_REMOVE(&base->active, ev, active_entries); + } goto rescan; } }