]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
backport to make channel_is_client() accurate
authorRoger Dingledine <arma@torproject.org>
Tue, 30 Jan 2018 23:05:39 +0000 (18:05 -0500)
committerNick Mathewson <nickm@torproject.org>
Fri, 16 Feb 2018 13:39:10 +0000 (08:39 -0500)
This commit takes a piece of commit af8cadf3a9 and a piece of commit
46fe353f25, with the goal of making channel_is_client() be based on what
sort of connection handshake the other side used, rather than seeing
whether the other side ever sent a create_fast cell to us.

changes/bug24898-029 [new file with mode: 0644]
src/or/channeltls.c
src/or/connection_or.c

diff --git a/changes/bug24898-029 b/changes/bug24898-029
new file mode 100644 (file)
index 0000000..f56dee5
--- /dev/null
@@ -0,0 +1,7 @@
+  o Minor bugfixes:
+    - Make the internal channel_is_client() function look at what sort
+      of connection handshake the other side used, rather than whether
+      the other side ever sent a create_fast cell to us. Backports part
+      of the fixes from bug 24898.
+
+
index 09cca95b64bc599424d56a5658e57b1256c75a07..31641c3db09164c2940b9bcb5c93a8fac433a2b4 100644 (file)
@@ -1640,6 +1640,10 @@ channel_tls_process_netinfo_cell(cell_t *cell, channel_tls_t *chan)
         tor_assert(tor_digest_is_zero(
                   (const char*)(chan->conn->handshake_state->
                       authenticated_peer_id)));
+        /* If the client never authenticated, it's a tor client or bridge
+         * relay, and we must not use it for EXTEND requests (nor could we, as
+         * there are no authenticated peer IDs) */
+        channel_mark_client(TLS_CHAN_TO_BASE(chan));
         channel_set_circid_type(TLS_CHAN_TO_BASE(chan), NULL,
                chan->conn->link_proto < MIN_LINK_PROTO_FOR_WIDE_CIRC_IDS);
 
index dadfdc4380acbb784042115223d1c70de4c1e544..8beedcae724617e88ec307aa667715e09c08ff75 100644 (file)
@@ -1880,6 +1880,12 @@ connection_or_set_state_open(or_connection_t *conn)
   connection_or_change_state(conn, OR_CONN_STATE_OPEN);
   control_event_or_conn_status(conn, OR_CONN_EVENT_CONNECTED, 0);
 
+  /* Link protocol 3 appeared in Tor 0.2.3.6-alpha, so any connection
+   * that uses an earlier link protocol should not be treated as a relay. */
+  if (conn->link_proto < 3) {
+    channel_mark_client(TLS_CHAN_TO_BASE(conn->chan));
+  }
+
   or_handshake_state_free(conn->handshake_state);
   conn->handshake_state = NULL;
   connection_start_reading(TO_CONN(conn));