aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-08-06 16:41:57 -0400
committerNick Mathewson <nickm@torproject.org>2013-09-03 15:38:25 -0400
commitd819663b661aea4f276404224fec6fe9c33f0bd9 (patch)
treefa9a12e2fd4f9a18034db98e2d31681a7c1b4de9 /src/common/compat.c
parent031e695aa50f24000ec112d535636807167be436 (diff)
downloadtor-d819663b661aea4f276404224fec6fe9c33f0bd9.tar
tor-d819663b661aea4f276404224fec6fe9c33f0bd9.tar.gz
Avoid a double-close on one failing case of the socketpair replacement code
Fix for bug 9400, spotted by coverity. Bug introduced in revision 2cb4f7a4 (subversion revision r389).
Diffstat (limited to 'src/common/compat.c')
-rw-r--r--src/common/compat.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index bf6a0a424..d88c5f92d 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -1281,7 +1281,6 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
goto tidy_up_and_fail;
if (size != sizeof(listen_addr))
goto abort_tidy_up_and_fail;
- tor_close_socket(listener);
/* Now check we are talking to ourself by matching port and host on the
two sockets. */
if (getsockname(connector, (struct sockaddr *) &connect_addr, &size) == -1)
@@ -1292,6 +1291,7 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
|| listen_addr.sin_port != connect_addr.sin_port) {
goto abort_tidy_up_and_fail;
}
+ tor_close_socket(listener);
fd[0] = connector;
fd[1] = acceptor;