]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
r13325@catbus: nickm | 2007-06-08 15:02:37 -0400
authorNick Mathewson <nickm@torproject.org>
Fri, 8 Jun 2007 19:02:39 +0000 (19:02 +0000)
committerNick Mathewson <nickm@torproject.org>
Fri, 8 Jun 2007 19:02:39 +0000 (19:02 +0000)
 Parse networkstatuses (v2, vote, and consensus) after generating them, and fail fast if there is a parse error.

svn:r10540

ChangeLog
src/or/dirserv.c
src/or/dirvote.c

index 889e34d3f45ffa5c62292ca1c317de9612a21609..63ee70a0e4feb2d2c0a21f7b9ed72a8382f865c9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,10 @@ Changes in version 0.2.0.3-alpha - 2007-??-??
     - tor-gencert creates all files as readable to the file creator only, and
       write-protects the authority identity key.
 
+  o Minor features (directory authority):
+    - Fail quickly and (relatively) harmlessly if we generate a network
+      status document that is somehow malformed.
+
   o Deprecated features:
     - RedirectExits is now deprecated.
 
index 57c95e634fbd287938f1038fb6fd1953de9b8bc2..612e2917ae49924a1ccd4b8d0073bd7d7d42c42e 100644 (file)
@@ -1983,10 +1983,19 @@ format_networkstatus_vote(crypto_pk_env_t *private_key,
 
   note_crypto_pk_op(SIGN_DIR);
   if (router_append_dirobj_signature(outp,endp-outp,digest,private_key)<0) {
-    log_warn(LD_BUG, "Unable to sign router status.");
+    log_warn(LD_BUG, "Unable to sign networkstatus vote.");
     goto err;
   }
 
+  {
+    networkstatus_vote_t *v;
+    if (!(v = networkstatus_parse_vote_from_string(status, 1))) {
+      log_err(LD_BUG,"Generated a networkstatus vote we couldn't parse.");
+      goto err;
+    }
+    networkstatus_vote_free(v);
+  }
+
   goto done;
 
  err:
@@ -2195,6 +2204,15 @@ generate_networkstatus_opinion(int v2)
     goto done;
   }
 
+  {
+    networkstatus_t *ns;
+    if (!(ns = networkstatus_parse_from_string(status))) {
+      log_err(LD_BUG,"Generated a networkstatus we couldn't parse.");
+      goto done;
+    }
+    networkstatus_free(ns);
+  }
+
   {
     cached_dir_t **ns_ptr = &the_v2_networkstatus;
     if (*ns_ptr)
index ce7351c93e9f929bf18234c026ad4fc265b68638..19d8ef308d2cd8e55426ca558930feebc31ecfb8 100644 (file)
@@ -623,6 +623,17 @@ networkstatus_compute_consensus(smartlist_t *votes,
   SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
   smartlist_free(chunks);
 
+  {
+    networkstatus_vote_t *c;
+    if (!(c = networkstatus_parse_vote_from_string(result, 0))) {
+      log_err(LD_BUG,"Generated a networkstatus consensus we couldn't "
+              "parse.");
+      tor_free(result);
+      return NULL;
+    }
+    networkstatus_vote_free(c);
+  }
+
   return result;
 }