From 974c60e14ac1a088cd39d8c1e93dc895ccc286df Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sat, 21 Dec 2013 23:15:28 -0500 Subject: Refactor evmap_{io,signal}_active_() to tolerate bad inputs --- evmap.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/evmap.c b/evmap.c index 13305feb..26044b41 100644 --- a/evmap.c +++ b/evmap.c @@ -397,11 +397,13 @@ evmap_io_active_(struct event_base *base, evutil_socket_t fd, short events) struct event *ev; #ifndef EVMAP_USE_HT - EVUTIL_ASSERT(fd < io->nentries); + if (fd < 0 || fd >= io->nentries) + return; #endif GET_IO_SLOT(ctx, io, fd, evmap_io); - EVUTIL_ASSERT(ctx); + if (NULL == ctx) + return; LIST_FOREACH(ev, &ctx->events, ev_io_next) { if (ev->ev_events & events) event_active_nolock_(ev, ev->ev_events & events, 1); @@ -472,9 +474,12 @@ evmap_signal_active_(struct event_base *base, evutil_socket_t sig, int ncalls) struct evmap_signal *ctx; struct event *ev; - EVUTIL_ASSERT(sig < map->nentries); + if (sig < 0 || sig >= map->nentries) + return; GET_SIGNAL_SLOT(ctx, map, sig, evmap_signal); + if (!ctx) + return; LIST_FOREACH(ev, &ctx->events, ev_signal_next) event_active_nolock_(ev, EV_SIGNAL, ncalls); } -- cgit v1.2.1