[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/maint-0.2.9] Fix memory leak in bug 20716
commit 3b6da3f90ccad60517f5b639d5340a7e6489be27
Author: overcaffeinated <overcaffeinated@xxxxxxxxxx>
Date: Sat Nov 19 19:32:08 2016 +0000
Fix memory leak in bug 20716
newconn->address is strdup'ed twice when new_type == CONN_TYPE_AP
and conn->socket_family == AF_UNIX. Whilst here, juggle code to
make sure newconn->port is assigned from an initialised value in
the above case.
---
changes/bug20716 | 3 +++
src/or/connection.c | 11 +++++++----
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/changes/bug20716 b/changes/bug20716
new file mode 100644
index 0000000..37fd6fe
--- /dev/null
+++ b/changes/bug20716
@@ -0,0 +1,3 @@
+ o Minor bugfixes (client, memory leak):
+ - Fix a small memory leak when receiving AF_UNIX connections on
+ a SocksPort. Fixes bug 20716; bugfix on 0.2.6.3-alpha.
diff --git a/src/or/connection.c b/src/or/connection.c
index 721ee20..3fe7f45 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -1497,16 +1497,19 @@ connection_handle_listener_read(connection_t *conn, int new_type)
/* remember the remote address */
tor_addr_copy(&newconn->addr, &addr);
- newconn->port = port;
- newconn->address = tor_dup_addr(&addr);
+ if (new_type == CONN_TYPE_AP && conn->socket_family == AF_UNIX) {
+ newconn->port = 0;
+ newconn->address = tor_strdup(conn->address);
+ } else {
+ newconn->port = port;
+ newconn->address = tor_dup_addr(&addr);
+ }
if (new_type == CONN_TYPE_AP && conn->socket_family != AF_UNIX) {
log_info(LD_NET, "New SOCKS connection opened from %s.",
fmt_and_decorate_addr(&addr));
}
if (new_type == CONN_TYPE_AP && conn->socket_family == AF_UNIX) {
- newconn->port = 0;
- newconn->address = tor_strdup(conn->address);
log_info(LD_NET, "New SOCKS AF_UNIX connection opened");
}
if (new_type == CONN_TYPE_CONTROL) {
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits