From: Nick Mathewson Date: Mon, 9 Jan 2012 16:49:41 +0000 (-0500) Subject: Make evconnlistener work around bug in older Linux when getting nmapped X-Git-Tag: release-2.0.17-stable~23 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ecfc720a4f7666d468413a3b9b29908bff5ddb82;p=libevent Make evconnlistener work around bug in older Linux when getting nmapped Older Linuxes sometimes respond to some nmap probes by having accept() return a success but with socklen 0. That can lead to confusing behavior when you go to process the sockaddr. --- diff --git a/listener.c b/listener.c index a440f465..8dcbb0b3 100644 --- a/listener.c +++ b/listener.c @@ -390,6 +390,12 @@ listener_read_cb(evutil_socket_t fd, short what, void *p) evutil_socket_t new_fd = accept(fd, (struct sockaddr*)&ss, &socklen); if (new_fd < 0) break; + if (socklen == 0) { + /* This can happen with some older linux kernels in + * response to nmap. */ + evutil_closesocket(new_fd); + continue; + } if (!(lev->flags & LEV_OPT_LEAVE_SOCKETS_BLOCKING)) evutil_make_socket_nonblocking(new_fd);