From d6073cc7fa63f69b8fd657ab38402f25ca06296f Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sat, 6 Jan 2007 06:27:15 +0000 Subject: [PATCH] r11864@Kushana: nickm | 2007-01-06 01:25:59 -0500 Fix an XXXX012 in connection.c: prevent overflows on unfeasibly-high-bandwidth servers on 32-bit architectures. svn:r9282 --- ChangeLog | 3 +++ src/or/connection.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7dea592d60..ab9e1ea73a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -27,6 +27,9 @@ Changes in version 0.1.2.6-alpha - 2007-??-?? o Minor bugfixes: - Restore a warning message if we accidentally resolve an address that we weren't planning to resolve. + - Prevent an (unlikely) bug on 32-bit architectures that could make + directories send 503s incorrectly when BandwidthBurst plus 2 times + BandwidthRate was over to 2 GB. Changes in version 0.1.2.5-alpha - 2007-01-06 diff --git a/src/or/connection.c b/src/or/connection.c index f42182ba6f..e4a03ac61b 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -1183,9 +1183,9 @@ global_write_bucket_low(size_t attempt, int priority) if (priority == 1) { /* old-style v1 query */ /* Could we handle *two* of these requests within the next two seconds? */ - /* XXX012 make this robust against overflows */ - if (global_write_bucket + 2*(int)(get_options()->BandwidthRate) < - 2*(int)attempt) + int64_t can_write = (int64_t)global_write_bucket + + 2*get_options()->BandwidthRate; + if (can_write < 2*(int64_t)attempt) return 1; } else { /* v2 query */ /* no further constraints yet */