aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-11-23 13:05:22 -0500
committerNick Mathewson <nickm@torproject.org>2016-12-16 11:06:15 -0500
commit526b0e2ce2c5d31c70eb3e48eda59b34e9eb681d (patch)
tree27875ada4b03be777a3d52020d9061760e16241e /src
parentac67819396ac9e96c3dd65a5b5b23715e11eeec5 (diff)
downloadtor-526b0e2ce2c5d31c70eb3e48eda59b34e9eb681d.tar.gz
tor-526b0e2ce2c5d31c70eb3e48eda59b34e9eb681d.zip
Avoid division-by-zero in pathbias_check_*_success_count
Diffstat (limited to 'src')
-rw-r--r--src/or/entrynodes.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index bd30078540..860be9b56c 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -3402,10 +3402,13 @@ static void
pathbias_check_use_success_count(entry_guard_t *node)
{
const or_options_t *options = get_options();
+ const double EPSILON = 1.0e-9;
+
/* Note: We rely on the < comparison here to allow us to set a 0
* rate and disable the feature entirely. If refactoring, don't
* change to <= */
- if (pathbias_get_use_success_count(node)/node->pb.use_attempts
+ if (node->pb.use_attempts > EPSILON &&
+ pathbias_get_use_success_count(node)/node->pb.use_attempts
< pathbias_get_extreme_use_rate(options) &&
pathbias_get_dropguards(options)) {
node->pb.path_bias_disabled = 1;
@@ -3420,10 +3423,13 @@ static void
pathbias_check_close_success_count(entry_guard_t *node)
{
const or_options_t *options = get_options();
+ const double EPSILON = 1.0e-9;
+
/* Note: We rely on the < comparison here to allow us to set a 0
* rate and disable the feature entirely. If refactoring, don't
* change to <= */
- if (pathbias_get_close_success_count(node)/node->pb.circ_attempts
+ if (node->pb.circ_attempts > EPSILON &&
+ pathbias_get_close_success_count(node)/node->pb.circ_attempts
< pathbias_get_extreme_rate(options) &&
pathbias_get_dropguards(options)) {
node->pb.path_bias_disabled = 1;