]> git.meshlink.io Git - meshlink/commitdiff
Fix a bug that caused tinc to ignore all but the last listening socket.
authorGuus Sliepen <guus@tinc-vpn.org>
Tue, 21 Feb 2012 12:31:21 +0000 (13:31 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Tue, 21 Feb 2012 12:31:21 +0000 (13:31 +0100)
src/net_setup.c

index dfed7e56f8424a7018dc01880f728fd0ac878c19..299e3729e0cb131555d99238e8b4c2745325c69b 100644 (file)
@@ -580,6 +580,7 @@ static bool setup_myself(void) {
 
        /* Open sockets */
 
+       listen_sockets = 0;
        cfg = lookup_config(config_tree, "BindToAddress");
 
        do {
@@ -601,9 +602,12 @@ static bool setup_myself(void) {
                        return false;
                }
 
-               listen_sockets = 0;
-
                for(aip = ai; aip; aip = aip->ai_next) {
+                       if(listen_sockets >= MAXSOCKETS) {
+                               logger(LOG_ERR, "Too many listening sockets");
+                               return false;
+                       }
+
                        listen_socket[listen_sockets].tcp =
                                setup_listen_socket((sockaddr_t *) aip->ai_addr);