diff options
author | Nick Mathewson <nickm@torproject.org> | 2007-07-12 16:35:10 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2007-07-12 16:35:10 +0000 |
commit | c09f015b55a90e76432b781fe4c5adf80bf2ed4f (patch) | |
tree | 23d9a1d59647d89075af3d300cdc90e18a379532 | |
parent | 588a007b8af5e5a734845da38ae4f1ed18b480e7 (diff) | |
download | tor-c09f015b55a90e76432b781fe4c5adf80bf2ed4f.tar.gz tor-c09f015b55a90e76432b781fe4c5adf80bf2ed4f.zip |
r13732@catbus: nickm | 2007-07-12 12:35:06 -0400
Backport 10812: avoid roundoff-error-induced crash bugs when picking routers by bandwith.
svn:r10813
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | src/or/routerlist.c | 6 |
2 files changed, 9 insertions, 0 deletions
@@ -27,6 +27,9 @@ Changes in version 0.1.2.15 - 2007-0?-?? o Minor bugfixes (misc) - On Windows, we were preventing other processes from reading cached-routers while Tor was running. (Reported by janbar) + - Fix a possible (but very unlikely) bug in picking routers by bandwidth. + Add a log message to confirm that it is in fact unlikely. (Patch from + lodger.) - Backport miscellaneous cosmetic bugfixes. diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 9af9520844..4d6ed26ccb 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -1082,6 +1082,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); } |