mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-17 00:07:04 -04:00
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.
This commit is contained in:
parent
f032516718
commit
ecfc720a4f
@ -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);
|
evutil_socket_t new_fd = accept(fd, (struct sockaddr*)&ss, &socklen);
|
||||||
if (new_fd < 0)
|
if (new_fd < 0)
|
||||||
break;
|
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))
|
if (!(lev->flags & LEV_OPT_LEAVE_SOCKETS_BLOCKING))
|
||||||
evutil_make_socket_nonblocking(new_fd);
|
evutil_make_socket_nonblocking(new_fd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user