summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-11-07 11:14:45 -0500
committerDavid Goulet <dgoulet@torproject.org>2017-11-07 11:14:45 -0500
commite67f4441eb2646368e3e7cb1bcee403667b786f0 (patch)
tree01d165eb462a0a90784dab198ca867f81dda1d39
parent8171d9f50f985de743a415ae5bf61b97e91ce8c8 (diff)
downloadtor-e67f4441eb2646368e3e7cb1bcee403667b786f0.tar.gz
tor-e67f4441eb2646368e3e7cb1bcee403667b786f0.zip
Add a safe guard to avoid using a zeroed voting schedule
dirvote_get_next_valid_after_time() is the only public function that uses the voting schedule outside of the dirvote subsystem so if it is zeroed, recalculate its timing if we can that is if a consensus exists. Part of #24161 Signed-off-by: David Goulet <dgoulet@torproject.org>
-rw-r--r--src/or/dirvote.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index c5ceefecb4..33e5ea7d51 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -2859,6 +2859,13 @@ static voting_schedule_t voting_schedule;
time_t
dirvote_get_next_valid_after_time(void)
{
+ /* This is a safe guard in order to make sure that the voting schedule
+ * static object is at least initialized. Using this function with a zeroed
+ * voting schedule can lead to bugs. */
+ if (tor_mem_is_zero((const char *) &voting_schedule,
+ sizeof(voting_schedule))) {
+ dirvote_recalculate_timing(get_options(), time(NULL));
+ }
return voting_schedule.interval_starts;
}