[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r9282: Fix an XXXX012 in connection.c: prevent overflows on unfeasi (in tor/trunk: . src/or)



Author: nickm
Date: 2007-01-06 01:27:15 -0500 (Sat, 06 Jan 2007)
New Revision: 9282

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/connection.c
Log:
 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.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r11864] on c95137ef-5f19-0410-b913-86e773d04f59

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-01-06 06:26:53 UTC (rev 9281)
+++ tor/trunk/ChangeLog	2007-01-06 06:27:15 UTC (rev 9282)
@@ -27,6 +27,9 @@
   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

Modified: tor/trunk/src/or/connection.c
===================================================================
--- tor/trunk/src/or/connection.c	2007-01-06 06:26:53 UTC (rev 9281)
+++ tor/trunk/src/or/connection.c	2007-01-06 06:27:15 UTC (rev 9282)
@@ -1183,9 +1183,9 @@
 
   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 */