Fix listen_sockets overflow in close_network_connections()
[tinc] / src / net_setup.c
index 2cd5818..b88f526 100644 (file)
@@ -674,6 +674,7 @@ static bool add_listen_address(char *address, bool bindto) {
                }
 
                if(listen_sockets >= MAXSOCKETS) {
+                       listen_sockets = MAXSOCKETS;
                        logger(DEBUG_ALWAYS, LOG_ERR, "Too many listening sockets");
                        freeaddrinfo(ai);
                        return false;
@@ -1095,6 +1096,7 @@ static bool setup_myself(void) {
 #endif
 
                if(listen_sockets > MAXSOCKETS) {
+                       listen_sockets = MAXSOCKETS;
                        logger(DEBUG_ALWAYS, LOG_ERR, "Too many listening sockets");
                        return false;
                }