summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorovercaffeinated <overcaffeinated@airmail.cc>2016-11-19 19:32:08 +0000
committerNick Mathewson <nickm@torproject.org>2016-12-01 10:14:42 -0500
commit3b6da3f90ccad60517f5b639d5340a7e6489be27 (patch)
tree86b67f5024fa7de14d78c5824394109caab22aa7 /src/or
parent6c2174d44d01b4c231befe9de5ce2ffb042cc65d (diff)
downloadtor-3b6da3f90ccad60517f5b639d5340a7e6489be27.tar.gz
tor-3b6da3f90ccad60517f5b639d5340a7e6489be27.zip
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.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/connection.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 721ee20d27..3fe7f453e8 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) {