mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Avoid division-by-zero in pathbias_check_*_success_count
This commit is contained in:
parent
ac67819396
commit
526b0e2ce2
@ -3402,10 +3402,13 @@ static void
|
|||||||
pathbias_check_use_success_count(entry_guard_t *node)
|
pathbias_check_use_success_count(entry_guard_t *node)
|
||||||
{
|
{
|
||||||
const or_options_t *options = get_options();
|
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
|
/* Note: We rely on the < comparison here to allow us to set a 0
|
||||||
* rate and disable the feature entirely. If refactoring, don't
|
* rate and disable the feature entirely. If refactoring, don't
|
||||||
* change to <= */
|
* 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_extreme_use_rate(options) &&
|
||||||
pathbias_get_dropguards(options)) {
|
pathbias_get_dropguards(options)) {
|
||||||
node->pb.path_bias_disabled = 1;
|
node->pb.path_bias_disabled = 1;
|
||||||
@ -3420,10 +3423,13 @@ static void
|
|||||||
pathbias_check_close_success_count(entry_guard_t *node)
|
pathbias_check_close_success_count(entry_guard_t *node)
|
||||||
{
|
{
|
||||||
const or_options_t *options = get_options();
|
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
|
/* Note: We rely on the < comparison here to allow us to set a 0
|
||||||
* rate and disable the feature entirely. If refactoring, don't
|
* rate and disable the feature entirely. If refactoring, don't
|
||||||
* change to <= */
|
* 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_extreme_rate(options) &&
|
||||||
pathbias_get_dropguards(options)) {
|
pathbias_get_dropguards(options)) {
|
||||||
node->pb.path_bias_disabled = 1;
|
node->pb.path_bias_disabled = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user