From 3c7652ccdbb352351b92c2d00106646e01c87cb6 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 11 Sep 2007 20:17:20 +0000 Subject: [PATCH] r15045@catbus: nickm | 2007-09-11 11:52:29 -0400 Reject incoming votes when the valid-after time does not match the period that we're trying to vote for. svn:r11426 --- doc/TODO | 6 +++--- src/or/dirvote.c | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/doc/TODO b/doc/TODO index 09f8319d16..e355f1ebd7 100644 --- a/doc/TODO +++ b/doc/TODO @@ -1,4 +1,4 @@ -$Id$ +yes$Id$ Legend: SPEC!! - Not specified SPEC - Spec not finalized @@ -52,7 +52,7 @@ Things we'd like to do in 0.2.0.x: o Code to manage key certificates o Download as needed. o Code to download - o Code to retry download. + . Code to retry download. . Code to generate consensus from a list of votes * Detect whether votes are really all for the same period. . Push/pull documents as appropriate. @@ -66,7 +66,7 @@ Things we'd like to do in 0.2.0.x: - Fix all XXXX020s in vote code - Validate information properly. - Warn if we get a vote with different authorities than we know. - - Don't count votes with a different valid-after when generating + o Don't count votes with a different valid-after when generating the same consensus. - Dump certificates with the wrong time. Or just warn? - Warn authority ops when their certs are nearly invalid. diff --git a/src/or/dirvote.c b/src/or/dirvote.c index 2642679821..ea503a1eb4 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -1338,8 +1338,18 @@ dirvote_add_vote(const char *vote_body, const char **msg_out, int *status_out) } } - /* XXXX020 check times; make sure epochs match. */ + /* Is it for the right period? */ + if (vote->valid_after != voting_schedule.interval_starts) { + char tbuf1[ISO_TIME_LEN+1], tbuf2[ISO_TIME_LEN+1]; + format_iso_time(tbuf1, vote->valid_after); + format_iso_time(tbuf2, voting_schedule.interval_starts); + log_warn(LD_DIR, "Rejecting vote with valid-after time of %s; we were " + "expecting %s", tbuf1, tbuf2); + *msg_out = "Bad valid-after time"; + goto err; + } + /* Now see whether we already have a vote from this authority.*/ SMARTLIST_FOREACH(pending_vote_list, pending_vote_t *, v, { if (! memcmp(v->vote->cert->cache_info.identity_digest, vote->cert->cache_info.identity_digest,