]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
When we get an END cell before CONNECTED, don't report SOCKS success
authorNick Mathewson <nickm@torproject.org>
Wed, 16 Jan 2013 17:08:10 +0000 (12:08 -0500)
committerNick Mathewson <nickm@torproject.org>
Wed, 16 Jan 2013 17:09:49 +0000 (12:09 -0500)
Bug 7902; fix on 0.1.0.1-rc.

changes/bug7902 [new file with mode: 0644]
src/or/reasons.c
src/or/relay.c

diff --git a/changes/bug7902 b/changes/bug7902
new file mode 100644 (file)
index 0000000..051759d
--- /dev/null
@@ -0,0 +1,7 @@
+  o Minor bugfixes:
+    - When we receive a RELAY_END cell with the reason DONE, or with no
+      reason, before receiving a RELAY_CONNECTED cell, report the SOCKS
+      status as "connection refused."  Previously we reporting these
+      cases as success but then immediately closing the connection.
+      Fixes bug 7902; bugfix on 0.1.0.1-rc. Reported by "oftc_must_
+      be_destroyed."
index 26ad12e8fdc77778508288092d1de0be10e833a5..637f8cdc7d387a64385242b3d56b2698432c49a3 100644 (file)
@@ -105,7 +105,12 @@ stream_end_reason_to_socks5_response(int reason)
     case END_STREAM_REASON_DESTROY:
       return SOCKS5_GENERAL_ERROR;
     case END_STREAM_REASON_DONE:
-      return SOCKS5_SUCCEEDED;
+      /* Note that 'DONE' usually indicates a successful close from the other
+       * side of the stream... but if we receive it before a connected cell --
+       * that is, before we have sent a SOCKS reply -- that means that the
+       * other side of the circuit closed the connection before telling us it
+       * was complete. */
+      return SOCKS5_CONNECTION_REFUSED;
     case END_STREAM_REASON_TIMEOUT:
       return SOCKS5_TTL_EXPIRED;
     case END_STREAM_REASON_NOROUTE:
index bb3a8354426ef72a3bfc0d915317d9e5930b6aaf..2701263e5b9860e139b63f5758590b188030e5e4 100644 (file)
@@ -734,7 +734,11 @@ connection_ap_process_end_not_open(
     }
   }
 
-  if (rh->length > 0 && edge_reason_is_retriable(reason) &&
+  if (rh->length == 0) {
+    reason = END_STREAM_REASON_MISC;
+  }
+
+  if (edge_reason_is_retriable(reason) &&
       /* avoid retry if rend */
       !connection_edge_is_rendezvous_stream(edge_conn)) {
     const char *chosen_exit_digest =