aboutsummaryrefslogtreecommitdiff
path: root/src/or/routerparse.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-08-15 15:38:58 +0000
committerNick Mathewson <nickm@torproject.org>2007-08-15 15:38:58 +0000
commitd5bd7d9fa39971d24859493e62e1d3ba3d1dc906 (patch)
tree1acedc967d36204cff40d4ddfee74466db78ca7d /src/or/routerparse.c
parent60c2e9d99e071a08a6e7f6eee82d49477e32aeda (diff)
downloadtor-d5bd7d9fa39971d24859493e62e1d3ba3d1dc906.tar.gz
tor-d5bd7d9fa39971d24859493e62e1d3ba3d1dc906.zip
r14032@Kushana: nickm | 2007-08-15 11:35:16 -0400
Add unit tests for median functions; enforce sensible ranges for intervals and delays. svn:r11121
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r--src/or/routerparse.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index c9a231485f..ccf3e38ddb 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -1874,6 +1874,22 @@ networkstatus_parse_vote_from_string(const char *s, int is_vote)
(int) tor_parse_long(tok->args[1], 10, 0, INT_MAX, &ok, NULL);
if (!ok)
goto err;
+ if (ns->valid_after + MIN_VOTE_INTERVAL > ns->fresh_until) {
+ log_warn(LD_DIR, "Vote/consensus freshness interval is too short");
+ goto err;
+ }
+ if (ns->valid_after + MIN_VOTE_INTERVAL*2 > ns->valid_until) {
+ log_warn(LD_DIR, "Vote/consensus liveness interval is too short");
+ goto err;
+ }
+ if (ns->vote_seconds < MIN_VOTE_SECONDS) {
+ log_warn(LD_DIR, "Vote seconds is too short");
+ goto err;
+ }
+ if (ns->dist_seconds < MIN_DIST_SECONDS) {
+ log_warn(LD_DIR, "Dist seconds is too short");
+ goto err;
+ }
if ((tok = find_first_by_keyword(tokens, K_CLIENT_VERSIONS))) {
ns->client_versions = tok->args[0];