mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-15 15:16:52 +02:00
Prevent DOS by asserts in TCP tuning (#2492)
* Prevent DOS by asserts in TCP tuning -Propagates socket option errors from the tuning functions to the callers. -Asserts a subset of error conditions during tuning, excluding external network causes. -Checks tuning results in 3 call sites and treats them like failures to connect, accept, etc. * Fix variable name * Remove lambda requiring C++11
This commit is contained in:
@@ -136,6 +136,7 @@ void zmq::tcp_connecter_t::out_event ()
|
||||
handle_valid = false;
|
||||
|
||||
const fd_t fd = connect ();
|
||||
|
||||
// Handle the error condition by attempt to reconnect.
|
||||
if (fd == retired_fd) {
|
||||
close ();
|
||||
@@ -143,10 +144,15 @@ void zmq::tcp_connecter_t::out_event ()
|
||||
return;
|
||||
}
|
||||
|
||||
tune_tcp_socket (fd);
|
||||
tune_tcp_keepalives (fd, options.tcp_keepalive, options.tcp_keepalive_cnt,
|
||||
options.tcp_keepalive_idle, options.tcp_keepalive_intvl);
|
||||
tune_tcp_maxrt (fd, options.tcp_maxrt);
|
||||
int rc = tune_tcp_socket (fd);
|
||||
rc = rc | tune_tcp_keepalives (fd, options.tcp_keepalive, options.tcp_keepalive_cnt,
|
||||
options.tcp_keepalive_idle, options.tcp_keepalive_intvl);
|
||||
rc = rc | tune_tcp_maxrt (fd, options.tcp_maxrt);
|
||||
if (rc != 0) {
|
||||
close ();
|
||||
add_reconnect_timer ();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the engine object for this connection.
|
||||
stream_engine_t *engine = new (std::nothrow)
|
||||
|
Reference in New Issue
Block a user