[or-cvs] bugfix: when we fail to bind or listen on an incoming or ou...

arma at seul.org arma at seul.org
Sat Apr 1 10:23:00 UTC 2006


Update of /home2/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/cvs/tor/src/or

Modified Files:
	connection.c 
Log Message:
bugfix: when we fail to bind or listen on an incoming or outgoing
socket, we should close it before failing. otherwise we just
leak it. (thanks to weasel for finding.)


Index: connection.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.448
retrieving revision 1.449
diff -u -p -d -r1.448 -r1.449
--- connection.c	19 Mar 2006 03:55:48 -0000	1.448
+++ connection.c	1 Apr 2006 10:22:57 -0000	1.449
@@ -555,12 +555,14 @@ connection_create_listener(const char *l
       helpfulhint = ". Is Tor already running?";
     log_warn(LD_NET, "Could not bind to %s:%u: %s%s", address, usePort,
              tor_socket_strerror(e), helpfulhint);
+    tor_close_socket(s);
     goto err;
   }
 
   if (listen(s,SOMAXCONN) < 0) {
     log_warn(LD_NET, "Could not listen on %s:%u: %s", address, usePort,
              tor_socket_strerror(tor_socket_errno(s)));
+    tor_close_socket(s);
     goto err;
   }
 
@@ -792,6 +794,7 @@ connection_connect(connection_t *conn, c
       if (bind(s, (struct sockaddr*)&ext_addr, sizeof(ext_addr)) < 0) {
         log_warn(LD_NET,"Error binding network socket: %s",
                  tor_socket_strerror(tor_socket_errno(s)));
+        tor_close_socket(s);
         return -1;
       }
     }



More information about the tor-commits mailing list