summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-11-07 10:17:13 -0500
committerNick Mathewson <nickm@torproject.org>2016-11-07 11:01:21 -0500
commit85970f70475af7f8bd6666cbdebf5bfa3095625d (patch)
tree9de6d61f53a0fe9997bc7e03f30723d88adadec2
parent1fdf6e5814ae50ed93338644f97c65b497463141 (diff)
downloadtor-85970f70475af7f8bd6666cbdebf5bfa3095625d.tar.gz
tor-85970f70475af7f8bd6666cbdebf5bfa3095625d.zip
Always increment delays by at least 1.
-rw-r--r--src/or/directory.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index f83f622030..ee42e2cd9b 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -3803,11 +3803,14 @@ next_random_exponential_delay(int delay, int max_delay)
} else if (delay) {
max_increment = INT_MAX-1;
} else {
- max_increment = 1; /* we're always willing to slow down a little. */
+ max_increment = 1;
}
- /* the + 1 here is so that we include the end of the interval */
- int increment = crypto_rand_int(max_increment+1);
+ if (BUG(max_increment < 1))
+ max_increment = 1;
+
+ /* the + 1 here is so that we always wait longer than last time. */
+ int increment = crypto_rand_int(max_increment)+1;
if (increment < max_delay - delay)
return delay + increment;