aboutsummaryrefslogtreecommitdiff
path: root/src/or/connection.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-12-28 22:49:32 -0500
committerNick Mathewson <nickm@torproject.org>2012-12-28 22:49:32 -0500
commitd3aabf4db176a44d19046b58b99f2edb8c5f49bb (patch)
treed804e239d5e0c4993c82f40cb97b25a1f7f73132 /src/or/connection.c
parentb509ead20d93277697c1cb961a2ae520bce7fd7f (diff)
downloadtor-d3aabf4db176a44d19046b58b99f2edb8c5f49bb.tar.gz
tor-d3aabf4db176a44d19046b58b99f2edb8c5f49bb.zip
Fix various small leaks on error cases
Spotted by coverity, bug 7816, bugfix on various versions.
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 4c6826269d..8c4228e5cc 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -992,6 +992,7 @@ connection_listener_new(const struct sockaddr *listensockaddr,
if (bind(s, listensockaddr, (socklen_t)sizeof(struct sockaddr_un)) == -1) {
log_warn(LD_NET,"Bind to %s failed: %s.", address,
tor_socket_strerror(tor_socket_errno(s)));
+ tor_close_socket(s);
goto err;
}
#ifdef HAVE_PWD_H
@@ -1000,9 +1001,11 @@ connection_listener_new(const struct sockaddr *listensockaddr,
if (pw == NULL) {
log_warn(LD_NET,"Unable to chown() %s socket: user %s not found.",
address, options->User);
+ tor_close_socket(s);
} else if (chown(address, pw->pw_uid, pw->pw_gid) < 0) {
log_warn(LD_NET,"Unable to chown() %s socket: %s.",
address, strerror(errno));
+ tor_close_socket(s);
goto err;
}
}