From c1d96358d49a4583b8aa9bdb1e8d73c70f9d8d06 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 1 Jun 2021 16:18:23 -0400 Subject: Use native timegm when available. Continue having a tor_gmtime_impl() unit test so that we can detect any problems in our replacement function; add a new test function to make sure that gmtime<->timegm are a round-trip on now-ish times. This is a fix for bug #40383, wherein we ran into trouble because tor_timegm() does not believe that time_t should include a count of leap seconds, but FreeBSD's gmtime believes that it should. This disagreement meant that for a certain amount of time each day, instead of calculating the most recent midnight, our voting-schedule functions would calculate the second-most-recent midnight, and lead to an assertion failure. I am calling this a bugfix on 0.2.0.3-alpha when we first started calculating our voting schedule in this way. --- changes/bug40383 | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 changes/bug40383 (limited to 'changes') diff --git a/changes/bug40383 b/changes/bug40383 new file mode 100644 index 0000000000..c4ca46fac7 --- /dev/null +++ b/changes/bug40383 @@ -0,0 +1,7 @@ + o Minor bugfixes (timekeeping): + - Calculate the time of day correctly on systems where the time_t + type includes leap seconds. (This is not the case on most + operating systems, but on those where it occurs, our tor_timegm + function did not correctly invert the system's gmtime function, + which could result in assertion failures when calculating + voting schedules.) Fixes bug 40383; bugfix on 0.2.0.3-alpha. -- cgit v1.2.3-54-g00ecf