diff options
author | Nick Mathewson <nickm@torproject.org> | 2021-06-01 16:18:23 -0400 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2021-07-06 13:33:05 +0300 |
commit | c1d96358d49a4583b8aa9bdb1e8d73c70f9d8d06 (patch) | |
tree | 47d79f59872c97624310adca4f3a981cb2159d8a /src/lib/encoding/time_fmt.h | |
parent | 8b6e919086ad6dde681516fe52d744afa3ffcc89 (diff) | |
download | tor-c1d96358d49a4583b8aa9bdb1e8d73c70f9d8d06.tar.gz tor-c1d96358d49a4583b8aa9bdb1e8d73c70f9d8d06.zip |
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.
Diffstat (limited to 'src/lib/encoding/time_fmt.h')
-rw-r--r-- | src/lib/encoding/time_fmt.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/lib/encoding/time_fmt.h b/src/lib/encoding/time_fmt.h index 80e47c5332..4adccb5990 100644 --- a/src/lib/encoding/time_fmt.h +++ b/src/lib/encoding/time_fmt.h @@ -18,6 +18,8 @@ #include <sys/types.h> #endif +#include "lib/testsupport/testsupport.h" + struct tm; struct timeval; @@ -41,4 +43,8 @@ int parse_iso_time_nospace(const char *cp, time_t *t); int parse_http_time(const char *buf, struct tm *tm); int format_time_interval(char *out, size_t out_len, long interval); +#ifdef TIME_FMT_PRIVATE +STATIC int tor_timegm_impl(const struct tm *tm, time_t *time_out); +#endif + #endif /* !defined(TOR_TIME_FMT_H) */ |