]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Ensure adding an event does not have an fd of -1
authorRoy Marples <roy@marples.name>
Wed, 13 May 2015 01:53:01 +0000 (01:53 +0000)
committerRoy Marples <roy@marples.name>
Wed, 13 May 2015 01:53:01 +0000 (01:53 +0000)
eloop.c

diff --git a/eloop.c b/eloop.c
index ed608f0611817b2b36778afdb485cb8cd2cd985e..1a472af2c2bae74812d4865502f082d32b53c7a3 100644 (file)
--- 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) {