]> granicus.if.org Git - libevent/commitdiff
Avoid leaking fds on evconnlistener with no callback set
authorNick Mathewson <nickm@torproject.org>
Thu, 20 Dec 2012 16:47:09 +0000 (11:47 -0500)
committerNick Mathewson <nickm@torproject.org>
Thu, 20 Dec 2012 16:47:09 +0000 (11:47 -0500)
There's no way to retrieve an fd from an evconnlistener whose
callback has been cleared, so we had better close any such fd.

Found by coverity; CID 739725.

listener.c

index d21e8dbe443f0fc69ff961f20b695ab6803d8cf6..2b67b525e24d962295857c318311f3e95225df32 100644 (file)
@@ -407,6 +407,7 @@ listener_read_cb(evutil_socket_t fd, short what, void *p)
                        evutil_make_socket_nonblocking(new_fd);
 
                if (lev->cb == NULL) {
+                       evutil_closesocket(new_fd);
                        UNLOCK(lev);
                        return;
                }