From 656b7761a81155047af6b41fd27c2aa6663b008e Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 12 Jul 2007 16:34:45 +0000 Subject: [PATCH] r13730@catbus: nickm | 2007-07-12 12:32:40 -0400 Patch from lodger: avoid roundoff-error-induced crash bugs when picking routers by bandwidth. Also, remove listed backports for 0.1.2.x; that list is now in TODO.012 svn:r10812 --- ChangeLog | 10 +++++++--- doc/TODO | 4 ---- src/or/routerlist.c | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1b65e2ef3b..3b3191f06a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,6 +41,11 @@ Changes in version 0.2.0.3-alpha - 2007-??-?? - Fix a crash bug when router descriptors end at a 4096-byte boundary on disk. [Bugfix on 0.1.2.x] + o Minor bugfixes (core protocol): + - When sending destroy cells from a circuit's origin, don't include + the reason for tearing down the circuit. The spec says we didn't, + and now we actually don't. Reported by lodger. [Bugfix on 0.1.2.x] + o Minor bugfixes (directory): - Fix another crash bug related to extra-info caching. (Bug found by Peter Palfrader.) [Bugfix on 0.2.0.2-alpha] @@ -75,9 +80,6 @@ Changes in version 0.2.0.3-alpha - 2007-??-?? o Security fixes (BSD natd support): - Fix a possible buffer overrun when using BSD natd support. Bug found by croup. - - When sending destroy cells from a circuit's origin, don't include - the reason for tearing down the circuit. The spec says we didn't, - and now we actually don't. Reported by lodger. [Bugfix on 0.1.2.x] Changes in version 0.2.0.2-alpha - 2007-06-02 @@ -271,6 +273,8 @@ Changes in version 0.2.0.1-alpha - 2007-06-01 we restart. - Add even more asserts to hunt down bug 417. - Build without verbose warnings even on (not-yet-released) gcc 4.2. + - Fix a possible (but very unlikely) bug in picking routers by bandwidth. + Add a log message to confirm that it is in fact unlikely. o Minor bugfixes (controller): - Make 'getinfo fingerprint' return a 551 error if we're not a diff --git a/doc/TODO b/doc/TODO index ad1cf3c831..865696cacc 100644 --- a/doc/TODO +++ b/doc/TODO @@ -15,10 +15,6 @@ P - phobos claims Documentation and testing on 0.1.2.x-final series - - Pending backports for 0.1.2.x: - - r10148: Open cached-routers with FILE_SHARE_READ on win32. - - r10493: Weight guard selection by bandwidth. - N - Test guard unreachable logic; make sure that we actually attempt to connect to guards that we think are unreachable from time to time. Make sure that we don't freak out when the network is down. diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 39da0bd0b6..944245d140 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -1294,6 +1294,12 @@ smartlist_choose_by_bandwidth(smartlist_t *sl, int for_exit, int statuses) if (tmp >= rand_bw) break; } + if (i == smartlist_len(sl)) { + /* This is possible due to round-off error. */ + --i; + log_warn(LD_BUG, "Round-off error in computing bandwidth had an effect on " + " which router we chose. Please tell the developers."); + } tor_free(bandwidths); return smartlist_get(sl, i); }