aboutsummaryrefslogtreecommitdiff
path: root/src/or/routerlist.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2018-01-07 02:15:18 -0500
committerRoger Dingledine <arma@torproject.org>2018-01-07 02:15:18 -0500
commit40cd992abbd4d06023cf14c39c337e4aa62416ec (patch)
treed5b8a0333835a83f813f41f462f3cde3e3559dda /src/or/routerlist.c
parent44aa1adf350ed790365eb3c8f97f35da6a4247ab (diff)
downloadtor-40cd992abbd4d06023cf14c39c337e4aa62416ec.tar.gz
tor-40cd992abbd4d06023cf14c39c337e4aa62416ec.zip
avoid calling format_iso_time() with TIME_MAX
If we tried to move a descriptor from routerlist->old_routers back into the current routerlist, we were preparing a buffer with format_iso_time() on ri->cert_expiration_time, and doing it preemptively since router_add_to_routerlist() might free ri so we wouldn't be able to get at it later in the function. But if the descriptor we're moving doesn't have any ed signature, then its cert will be marked to expire at TIME_MAX, and handing TIME_MAX to format_iso_time() generates this log warning: correct_tm(): Bug: gmtime(9223372036854775807) failed with error Value too large for defined data type: Rounding down to 2037 The fix is to preemptively remember the expiry time, but only prepare the buffer if we know we're going to need it. Bugfix on commit a1b0a0b9, which came about as part of a fix for bug 20020, and which is not yet in any released version of Tor (hence no changes file).
Diffstat (limited to 'src/or/routerlist.c')
-rw-r--r--src/or/routerlist.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index d8c8a81738..2815c60963 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -5207,14 +5207,14 @@ update_consensus_router_descriptor_downloads(time_t now, int is_vote,
SMARTLIST_FOREACH_BEGIN(no_longer_old, signed_descriptor_t *, sd) {
const char *msg;
was_router_added_t r;
+ time_t tmp_cert_expiration_time;
routerinfo_t *ri = routerlist_reparse_old(rl, sd);
if (!ri) {
log_warn(LD_BUG, "Failed to re-parse a router.");
continue;
}
- /* need to compute this now, since add_to_routerlist may free. */
- char time_cert_expires[ISO_TIME_LEN+1];
- format_iso_time(time_cert_expires, ri->cert_expiration_time);
+ /* need to remember for below, since add_to_routerlist may free. */
+ tmp_cert_expiration_time = ri->cert_expiration_time;
r = router_add_to_routerlist(ri, &msg, 1, 0);
if (WRA_WAS_OUTDATED(r)) {
@@ -5224,7 +5224,9 @@ update_consensus_router_descriptor_downloads(time_t now, int is_vote,
msg?msg:"???");
if (r == ROUTER_CERTS_EXPIRED) {
char time_cons[ISO_TIME_LEN+1];
+ char time_cert_expires[ISO_TIME_LEN+1];
format_iso_time(time_cons, consensus->valid_after);
+ format_iso_time(time_cert_expires, tmp_cert_expiration_time);
log_warn(LD_DIR, " (I'm looking at a consensus from %s; This "
"router's certificates began expiring at %s.)",
time_cons, time_cert_expires);