commit 2ba58f275cef6ae70c0d6f5a94f8bd3ff99f1e5e Author: Nick Mathewson nickm@torproject.org Date: Tue May 16 11:20:12 2017 -0400
Fix crash when starting with LearnCircuitBuildTimeout 0.
Before we've set our options, we can neither call get_options() nor networkstatus_get_latest_consensus().
Fixes bug 22252; bugfix on 4d9d2553baa6856b1d85ec26baa1ac3d2c24832a in 0.2.9.3-alpha. --- changes/bug22252 | 3 +++ src/or/circuitstats.c | 12 ++++++++++-- src/or/circuitstats.h | 3 +++ src/or/config.c | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/changes/bug22252 b/changes/bug22252 new file mode 100644 index 0000000..42b9d8e --- /dev/null +++ b/changes/bug22252 @@ -0,0 +1,3 @@ + o Minor bugfixes (configuration): + - Do not crash when starting with LearnCircuitBuildTimeout 0. + Fixes bug 22252; bugfix on 0.2.9.3-alpha. diff --git a/src/or/circuitstats.c b/src/or/circuitstats.c index 418acc0..d4487cf 100644 --- a/src/or/circuitstats.c +++ b/src/or/circuitstats.c @@ -107,11 +107,19 @@ get_circuit_build_timeout_ms(void) int circuit_build_times_disabled(void) { + return circuit_build_times_disabled_(get_options()); +} + +/** As circuit_build_times_disabled, but take options as an argument. */ +int +circuit_build_times_disabled_(const or_options_t *options, + int ignore_consensus) +{ if (unit_tests) { return 0; } else { - const or_options_t *options = get_options(); - int consensus_disabled = networkstatus_get_param(NULL, "cbtdisabled", + int consensus_disabled = + ignore_consensus ? 0 : networkstatus_get_param(NULL, "cbtdisabled", 0, 0, 1); int config_disabled = !options->LearnCircuitBuildTimeout; int dirauth_disabled = options->AuthoritativeDir; diff --git a/src/or/circuitstats.h b/src/or/circuitstats.h index 72b1609..38a994d 100644 --- a/src/or/circuitstats.h +++ b/src/or/circuitstats.h @@ -18,6 +18,9 @@ double get_circuit_build_close_time_ms(void); double get_circuit_build_timeout_ms(void);
int circuit_build_times_disabled(void); +int circuit_build_times_disabled_(const or_options_t *options, + int ignore_consensus); + int circuit_build_times_enough_to_compute(const circuit_build_times_t *cbt); void circuit_build_times_update_state(const circuit_build_times_t *cbt, or_state_t *state); diff --git a/src/or/config.c b/src/or/config.c index 3693cdf..dd9f4eb 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -3450,7 +3450,7 @@ options_validate(or_options_t *old_options, or_options_t *options, int severity = LOG_NOTICE; /* Be a little quieter if we've deliberately disabled * LearnCircuitBuildTimeout. */ - if (circuit_build_times_disabled()) { + if (circuit_build_times_disabled_(options, 1)) { severity = LOG_INFO; } log_fn(severity, LD_CONFIG, "You disabled LearnCircuitBuildTimeout, but "