summaryrefslogtreecommitdiff
path: root/src/or/circuitbuild.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-02-15 16:23:43 -0500
committerNick Mathewson <nickm@torproject.org>2013-02-15 16:23:43 -0500
commitd6634001c9063323643e3ddfe8905c250a6d60d7 (patch)
tree7efa13432f31719ec5b4446f4ed00d0d4d34cd51 /src/or/circuitbuild.c
parent5fcc5dfa779fcdc84cb7249749b7fbb782f15a10 (diff)
parent076654ce8423d2b8ab7285b22c13d4002942bd8b (diff)
downloadtor-d6634001c9063323643e3ddfe8905c250a6d60d7.tar.gz
tor-d6634001c9063323643e3ddfe8905c250a6d60d7.zip
Merge remote-tracking branch 'public/wide_circ_ids'
Conflicts: src/or/channel.h src/or/connection_or.c src/or/cpuworker.c
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r--src/or/circuitbuild.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 45da6b02a5..40751e02b1 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -100,7 +100,7 @@ get_unique_circ_id_by_chan(channel_t *chan)
{
circid_t test_circ_id;
circid_t attempts=0;
- circid_t high_bit;
+ circid_t high_bit, max_range;
tor_assert(chan);
@@ -110,17 +110,17 @@ get_unique_circ_id_by_chan(channel_t *chan)
"a client with no identity.");
return 0;
}
- high_bit =
- (chan->circ_id_type == CIRC_ID_TYPE_HIGHER) ? 1<<15 : 0;
+ max_range = (chan->wide_circ_ids) ? (1u<<31) : (1u<<15);
+ high_bit = (chan->circ_id_type == CIRC_ID_TYPE_HIGHER) ? max_range : 0;
do {
- /* Sequentially iterate over test_circ_id=1...1<<15-1 until we find a
+ /* Sequentially iterate over test_circ_id=1...max_range until we find a
* circID such that (high_bit|test_circ_id) is not already used. */
test_circ_id = chan->next_circ_id++;
- if (test_circ_id == 0 || test_circ_id >= 1<<15) {
+ if (test_circ_id == 0 || test_circ_id >= max_range) {
test_circ_id = 1;
chan->next_circ_id = 2;
}
- if (++attempts > 1<<15) {
+ if (++attempts > max_range) {
/* Make sure we don't loop forever if all circ_id's are used. This
* matters because it's an external DoS opportunity.
*/