aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-12-07 11:13:11 -0500
committerNick Mathewson <nickm@torproject.org>2016-12-07 11:13:11 -0500
commit0815f96416676ace7cfdb5c29000d8cd6ee3459f (patch)
treee0f22eed6df3293493acf94a7794fe243589c1fc /src
parentfce425e3ff0281de29f04ac46d8c395befee607d (diff)
downloadtor-0815f96416676ace7cfdb5c29000d8cd6ee3459f.tar.gz
tor-0815f96416676ace7cfdb5c29000d8cd6ee3459f.zip
Fix a BUG() warning from next_random_exponential_delay().
Fixes 20875; this code is as suggested by teor on the ticket. Thanks!
Diffstat (limited to 'src')
-rw-r--r--src/or/directory.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index f4fd521929..fce48c6e95 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -3787,10 +3787,12 @@ STATIC int
next_random_exponential_delay(int delay, int max_delay)
{
/* Check preconditions */
+ if (BUG(max_delay < 0))
+ max_delay = 0;
if (BUG(delay > max_delay))
delay = max_delay;
- if (BUG(delay == INT_MAX))
- delay -= 1; /* prevent overflow */
+ if (delay == INT_MAX)
+ return INT_MAX; /* prevent overflow */
if (BUG(delay < 0))
delay = 0;