]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Always increment delays by at least 1.
authorNick Mathewson <nickm@torproject.org>
Mon, 7 Nov 2016 15:17:13 +0000 (10:17 -0500)
committerNick Mathewson <nickm@torproject.org>
Mon, 7 Nov 2016 16:01:21 +0000 (11:01 -0500)
src/or/directory.c

index f83f6220302a63819193c024a069b42368b7941e..ee42e2cd9b2a1c50ffe07def19b33eae6c25401a 100644 (file)
@@ -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;