]> granicus.if.org Git - sudo/commitdiff
Fix infinite loop that could be triggered by sudo_ev_loopbreak()
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 6 Jan 2014 18:20:38 +0000 (11:20 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 6 Jan 2014 18:20:38 +0000 (11:20 -0700)
and sudo_ev_loopcontinue().

common/event.c

index a7bdf7e6bf11801fb3e6d2b838645e3b10e98b82..8c398cf6556e43bfa7892a9096ba6cb02a868d22 100644 (file)
@@ -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;
                }
            }