From: Roy Marples Date: Wed, 13 May 2015 01:53:01 +0000 (+0000) Subject: Ensure adding an event does not have an fd of -1 X-Git-Tag: v6.9.0~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f53b99216f097322ce0e3b22ef47972aab225c35;p=thirdparty%2Fdhcpcd.git Ensure adding an event does not have an fd of -1 --- diff --git a/eloop.c b/eloop.c index ed608f06..1a472af2 100644 --- a/eloop.c +++ b/eloop.c @@ -142,6 +142,10 @@ eloop_event_add(struct eloop *eloop, int fd, assert(eloop != NULL); assert(read_cb != NULL || write_cb != NULL); + if (fd == -1) { + errno = EINVAL; + return -1; + } #ifdef HAVE_EPOLL memset(&epe, 0, sizeof(epe)); @@ -258,7 +262,6 @@ eloop_event_delete(struct eloop *eloop, int fd, int write_only) #endif assert(eloop != NULL); - assert(fd != -1); TAILQ_FOREACH(e, &eloop->events, next) { if (e->fd == fd) {