[or-cvs] r10534: Enfore that known_flags in networkstatus votes must be uniqu (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Fri Jun 8 18:41:12 UTC 2007


Author: nickm
Date: 2007-06-08 14:41:12 -0400 (Fri, 08 Jun 2007)
New Revision: 10534

Modified:
   tor/trunk/
   tor/trunk/src/or/dirvote.c
   tor/trunk/src/or/routerparse.c
Log:
 r13314 at catbus:  nickm | 2007-06-08 14:30:31 -0400
 Enfore that known_flags in networkstatus votes must be unique.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r13314] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/dirvote.c
===================================================================
--- tor/trunk/src/or/dirvote.c	2007-06-08 18:41:09 UTC (rev 10533)
+++ tor/trunk/src/or/dirvote.c	2007-06-08 18:41:12 UTC (rev 10534)
@@ -450,8 +450,6 @@
         ++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);

Modified: tor/trunk/src/or/routerparse.c
===================================================================
--- tor/trunk/src/or/routerparse.c	2007-06-08 18:41:09 UTC (rev 10533)
+++ tor/trunk/src/or/routerparse.c	2007-06-08 18:41:12 UTC (rev 10534)
@@ -1505,7 +1505,10 @@
       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 @@
   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 @@
 
   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();
 



More information about the tor-commits mailing list