]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Look at the right errno when sending reason for connect() failure
authorNick Mathewson <nickm@torproject.org>
Fri, 25 Mar 2011 20:14:42 +0000 (16:14 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 25 Mar 2011 22:32:28 +0000 (18:32 -0400)
In afe414 (tor-0.1.0.1-rc~173), when we moved to
connection_edge_end_errno(), we used it in handling errors from
connection_connect().  That's not so good, since by the time
connection_connect() returns, the socket is no longer set, and we're
supposed to be looking at the socket_errno return value from
connection_connect() instead.  So do what we should've done, and
look at the socket_errno value that we get from connection_connect().

changes/connect_err_reporting [new file with mode: 0644]
src/or/connection_edge.c

diff --git a/changes/connect_err_reporting b/changes/connect_err_reporting
new file mode 100644 (file)
index 0000000..61a46b6
--- /dev/null
@@ -0,0 +1,6 @@
+  o Minor bugfixes:
+    - Be more careful about reporting the correct error from a failed
+      connect() operation.  Under some circumstances, it was possible to
+      look at an incorrect value for errno when sending the end reason.
+      Bugfix on Tor-0.1.0.1-rc.
+
index 82b71395b5debcaae85a06f2482d3531e7c8792e..c75c06bc60eea8a3edecf90985e135062d8dc030 100644 (file)
@@ -2823,13 +2823,13 @@ connection_exit_connect(edge_connection_t *edge_conn)
 
   log_debug(LD_EXIT,"about to try connecting");
   switch (connection_connect(conn, conn->address, addr, port, &socket_error)) {
-    case -1:
-      /* XXX022 use socket_error below rather than trying to piece things
-       * together from the current errno, which may have been clobbered. */
-      connection_edge_end_errno(edge_conn);
+    case -1: {
+      int reason = errno_to_stream_end_reason(socket_error);
+      connection_edge_end(edge_conn, reason);
       circuit_detach_stream(circuit_get_by_edge_conn(edge_conn), edge_conn);
       connection_free(conn);
       return;
+    }
     case 0:
       conn->state = EXIT_CONN_STATE_CONNECTING;