]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
r17302@aud-055: nickm | 2008-07-23 14:55:28 +0200
authorNick Mathewson <nickm@torproject.org>
Wed, 23 Jul 2008 12:55:55 +0000 (12:55 +0000)
committerNick Mathewson <nickm@torproject.org>
Wed, 23 Jul 2008 12:55:55 +0000 (12:55 +0000)
 Never allow a circuit to be created with the same circid as a circuit that has been marked for close.  May be a fix for bug 779.  Needs testing.  Backport candidate.

svn:r16136

ChangeLog
src/or/circuitbuild.c
src/or/circuitlist.c
src/or/command.c
src/or/or.h

index 6f50e3c7e2490291806b82d1f7034d00e8ce798e..418c540bb716c9a5fdf03baae09e29b6bc3c20e3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,9 @@ Changes in version 0.2.1.3-alpha - 2008-07-xx
       or RENDEZVOUS_ESTABLISHED cell. This can save a second or two
       on the client side when connecting to a hidden service. Bugfix
       on 0.0.6pre1. Found and fixed by Christian Wilms; resolves bug 743.
+    - Ensure that two circuits can never exist on the same connection
+      with the same circuit ID, even if one is marked for close.  This
+      is conceivably a bugfix for bug 779; fixes a bug on 0.1.0.4-rc.
 
   o Minor features:
     - When relays do their initial bandwidth measurement, don't limit
index 354a9767e13753a866518517e1d65ed6b5d6b7a6..69ace8838e13b699b08ef792501679fb1187b9ee 100644 (file)
@@ -99,7 +99,7 @@ get_unique_circ_id_by_conn(or_connection_t *conn)
       return 0;
     }
     test_circ_id |= high_bit;
-  } while (circuit_get_by_circid_orconn(test_circ_id, conn));
+  } while (circuit_id_in_use_on_orconn(test_circ_id, conn));
   return test_circ_id;
 }
 
index 7bd3829f622a298fdf57f929eecf3d97faa6e8a1..adb0d7867e364c140a761fd0258efe30b366904d 100644 (file)
@@ -661,6 +661,14 @@ circuit_get_by_circid_orconn(uint16_t circ_id, or_connection_t *conn)
     return circ;
 }
 
+/** Return true iff the circuit ID <b>circ_id</b> is currently used by a
+ * circuit, marked or not, on <b>conn</b>. */
+int
+circuit_id_in_use_on_orconn(uint16_t circ_id, or_connection_t *conn)
+{
+  return circuit_get_by_circid_orconn_impl(circ_id, conn) != NULL;
+}
+
 /** Return the circuit that a given edge connection is using. */
 circuit_t *
 circuit_get_by_edge_conn(edge_connection_t *conn)
index 79e6133f19822012f9f23135af45e1699144dbb5..4a0884239680c66a9efecc0467daffb9c3afee85 100644 (file)
@@ -252,7 +252,7 @@ command_process_create_cell(cell_t *cell, or_connection_t *conn)
     return;
   }
 
-  if (circuit_get_by_circid_orconn(cell->circ_id, conn)) {
+  if (circuit_id_in_use_on_orconn(cell->circ_id, conn)) {
     routerinfo_t *router = router_get_by_digest(conn->identity_digest);
     log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
            "Received CREATE cell (circID %d) for known circ. "
index b81db6f7af2d4dc7f5fb4364a748a9276efdd426..ffcb686cbe31703cea3153dea1db4f26732d118f 100644 (file)
@@ -2623,6 +2623,7 @@ origin_circuit_t *origin_circuit_new(void);
 or_circuit_t *or_circuit_new(uint16_t p_circ_id, or_connection_t *p_conn);
 circuit_t *circuit_get_by_circid_orconn(uint16_t circ_id,
                                         or_connection_t *conn);
+int circuit_id_in_use_on_orconn(uint16_t circ_id, or_connection_t *conn);
 circuit_t *circuit_get_by_edge_conn(edge_connection_t *conn);
 void circuit_unlink_all_from_or_conn(or_connection_t *conn, int reason);
 origin_circuit_t *circuit_get_by_global_id(uint32_t id);