summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-06-08 18:41:12 +0000
committerNick Mathewson <nickm@torproject.org>2007-06-08 18:41:12 +0000
commit171969656c2cf6dc95308de06128ec9caf6eb035 (patch)
treee74cf78589faceb0e9444ce65fb16921fc3caf06 /src/or
parent7a6f3cd223a34b76b7bc183f0465fcfdddc405b2 (diff)
downloadtor-171969656c2cf6dc95308de06128ec9caf6eb035.tar.gz
tor-171969656c2cf6dc95308de06128ec9caf6eb035.zip
r13314@catbus: nickm | 2007-06-08 14:30:31 -0400
Enfore that known_flags in networkstatus votes must be unique. svn:r10534
Diffstat (limited to 'src/or')
-rw-r--r--src/or/dirvote.c2
-rw-r--r--src/or/routerparse.c17
2 files changed, 14 insertions, 5 deletions
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index 42e13a7d91..ce7351c93e 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -450,8 +450,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
++n_flag_voters[p];
if (!strcmp(fl, "Named"))
named_flag[v_sl_idx] = fl_sl_idx;
- /* XXXX020 somebody needs to make sure that there are no duplicate
- * entries in anybody's flag list. */
});
n_voter_flags[v_sl_idx] = smartlist_len(v->known_flags);
size[v_sl_idx] = smartlist_len(v->routerstatus_list);
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index e5645787c1..bb9c3c62b3 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -1505,7 +1505,10 @@ routerstatus_parse_entry_from_string(const char **s, smartlist_t *tokens,
int p = smartlist_string_pos(vote->known_flags, tok->args[i]);
if (p >= 0) {
vote_rs->flags |= (1<<p);
- break;
+ } else {
+ log_warn(LD_DIR, "Flags line had a flag %s not listed in known_flags.",
+ escaped(tok->args[i]));
+ goto err;
}
}
} else if (tok) {
@@ -1768,7 +1771,7 @@ networkstatus_parse_vote_from_string(const char *s, int is_vote)
directory_token_t *tok;
int ok;
struct in_addr in;
- int i;
+ int i, inorder;
if (router_get_networkstatus_v3_hash(s, ns_digest)) {
log_warn(LD_DIR, "Unable to compute digest of network-status");
@@ -1853,9 +1856,17 @@ networkstatus_parse_vote_from_string(const char *s, int is_vote)
tok = find_first_by_keyword(tokens, K_KNOWN_FLAGS);
ns->known_flags = smartlist_create();
- for (i = 0; i < tok->n_args; ++i)
+ inorder = 1;
+ for (i = 0; i < tok->n_args; ++i) {
smartlist_add(ns->known_flags, tok->args[i]);
+ if (i>0 && strcmp(tok->args[i-1], tok->args[i])>= 0)
+ inorder = 0;
+ }
tok->n_args = 0; /* suppress free of args members, but not of args itself. */
+ if (!inorder) {
+ log_warn(LD_DIR, "known-flags not in order");
+ goto err;
+ }
ns->voters = smartlist_create();