]> granicus.if.org Git - sudo/commitdiff
Only check an fd that is >= 0. Timeout-only events may have a
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 2 Nov 2013 16:13:54 +0000 (10:13 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 2 Nov 2013 16:13:54 +0000 (10:13 -0600)
negative fd.

common/event_select.c

index fc28d56e01f933e18937ddfbe4b8891ee57b2df4..3d4b3088a2052061e8e6900461792062099bd9bf 100644 (file)
@@ -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;