summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-08-07 20:19:38 +0000
committerNick Mathewson <nickm@torproject.org>2008-08-07 20:19:38 +0000
commit62340f1d766da299fa0b3f0f1a5a71dfd4603dce (patch)
tree87e7c753c083c83f0f050dc642485ee817df534e
parent355d84d1225c8185b06ce251ffd2be0a8c884218 (diff)
downloadtor-62340f1d766da299fa0b3f0f1a5a71dfd4603dce.tar.gz
tor-62340f1d766da299fa0b3f0f1a5a71dfd4603dce.zip
Backport to 0.2.0.x: Never allow a circuit to be created with the same circid as a circuit that has been marked for close. May fix 779. Needs testing.
svn:r16463
-rw-r--r--ChangeLog5
-rw-r--r--src/or/circuitbuild.c2
-rw-r--r--src/or/circuitlist.c8
-rw-r--r--src/or/command.c2
-rw-r--r--src/or/or.h1
5 files changed, 16 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 87865dab95..868753b525 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,9 @@
Changes in version 0.2.0.31 - 2008-08-??
+ o Major bugfixes:
+ - Make sure 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 bugfixes:
- Fix a small alignment and memory-wasting bug on buffer chunks. Spotted
by rovv.
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index bb302836f7..3be2689995 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -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;
}
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 7bd3829f62..adb0d7867e 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -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)
diff --git a/src/or/command.c b/src/or/command.c
index 552624fb76..f125f47690 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -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. "
diff --git a/src/or/or.h b/src/or/or.h
index e1a2fe6d9e..6f7d92cabf 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2568,6 +2568,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);