]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Avoid a double-close on one failing case of the socketpair replacement code
authorNick Mathewson <nickm@torproject.org>
Tue, 6 Aug 2013 20:41:57 +0000 (16:41 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 3 Sep 2013 19:38:25 +0000 (15:38 -0400)
Fix for bug 9400, spotted by coverity. Bug introduced in revision 2cb4f7a4
(subversion revision r389).

changes/bug9400 [new file with mode: 0644]
src/common/compat.c

diff --git a/changes/bug9400 b/changes/bug9400
new file mode 100644 (file)
index 0000000..9742240
--- /dev/null
@@ -0,0 +1,7 @@
+  o Minor bugfixes:
+
+    - Avoid double-closing the listener socket in our socketpair replacement
+      (used on Windows) in the case where the addresses on our opened
+      sockets don't match what we expected. Fixes bug 9400; bugfix on
+      every released Tor version. Found by Coverity.
+
index bf6a0a4243d83d717afabd3afe1f491a5263dcdd..d88c5f92dec40ab8010c7640374f1bd1a5c3786d 100644 (file)
@@ -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;