aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2006-04-01 10:22:57 +0000
committerRoger Dingledine <arma@torproject.org>2006-04-01 10:22:57 +0000
commite754664d620bf5aad76aa713b53299560497ac91 (patch)
treefff9b59fae16c7e840840c9133ff497b9f86890f /src/or/connection.c
parente47075e7716e2d310354da9a7cc070b52dba410d (diff)
downloadtor-e754664d620bf5aad76aa713b53299560497ac91.tar.gz
tor-e754664d620bf5aad76aa713b53299560497ac91.zip
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.) svn:r6284
Diffstat (limited to 'src/or/connection.c')
-rw-r--r--src/or/connection.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index c621fbbaf5..0c18735e13 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -555,12 +555,14 @@ connection_create_listener(const char *listenaddress, uint16_t listenport,
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, char *address,
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;
}
}