[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r12049: Learn the difference between "mismatched vote digest" and "m (in tor/trunk: . src/or)



Author: nickm
Date: 2007-10-19 12:41:32 -0400 (Fri, 19 Oct 2007)
New Revision: 12049

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/dirvote.c
   tor/trunk/src/or/or.h
   tor/trunk/src/or/test.c
Log:
 r15961@catbus:  nickm | 2007-10-19 12:40:15 -0400
 Learn the difference between "mismatched vote digest" and "mismatched vote times": the latter is more informative.



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

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-10-19 16:41:30 UTC (rev 12048)
+++ tor/trunk/ChangeLog	2007-10-19 16:41:32 UTC (rev 12049)
@@ -51,10 +51,13 @@
       listing.
     - Treat missing v3 keys or certificates as an error when running as a
       v3 directory authority.
-
     - If an authority doesn't have a qualified hostname, just put its address
-      in the 
+      in the vote.  This fixes the problem where we referred to "moria on
+      moria:9031."
+    - Distinguish between detached signatures for the wrong period, and
+      detached signatures for a divergent vote.
 
+
   o Minor bugfixes (v3 directory protocol)
     - Delete unverified-consensus when the real consensus is set.
     - Consider retrying a consensus networkstatus fetch immediately after one

Modified: tor/trunk/src/or/dirvote.c
===================================================================
--- tor/trunk/src/or/dirvote.c	2007-10-19 16:41:30 UTC (rev 12048)
+++ tor/trunk/src/or/dirvote.c	2007-10-19 16:41:32 UTC (rev 12049)
@@ -810,17 +810,36 @@
  * document as <b>target</b>. */
 int
 networkstatus_add_detached_signatures(networkstatus_vote_t *target,
-                                      ns_detached_signatures_t *sigs)
+                                      ns_detached_signatures_t *sigs,
+                                      const char **msg_out)
 {
   int r = 0;
   tor_assert(sigs);
   tor_assert(target);
   tor_assert(!target->is_vote);
 
+  /* Do the times seem right? */
+  if (target->valid_after != sigs->valid_after) {
+    *msg_out = "Valid-After times do not match "
+      "when adding detached signatures to consensus";
+    return -1;
+  }
+  if (target->fresh_until != sigs->fresh_until) {
+    *msg_out = "Fresh-until times do not match "
+      "when adding detached signatures to consensus";
+    return -1;
+  }
+  if (target->valid_until != sigs->valid_until) {
+    *msg_out = "Valid-until times do not match "
+      "when adding detached signatures to consensus";
+    return -1;
+  }
   /* Are they the same consensus? */
   if (memcmp(target->networkstatus_digest, sigs->networkstatus_digest,
-             DIGEST_LEN))
+             DIGEST_LEN)) {
+    *msg_out = "Digest mismatch when adding detached signatures to consensus";
     return -1;
+  }
 
   /* For each voter in src... */
   SMARTLIST_FOREACH(sigs->signatures, networkstatus_voter_info_t *, src_voter,
@@ -1612,7 +1631,7 @@
   }
 
   r = networkstatus_add_detached_signatures(pending_consensus,
-                                            sigs);
+                                            sigs, msg_out);
 
   if (r >= 0) {
     char *new_detached =
@@ -1644,7 +1663,7 @@
     pending_consensus_signatures = new_detached;
     *msg_out = "Signatures added";
   } else {
-    *msg_out = "Digest mismatch when adding detached signatures";
+    goto err;
   }
 
   goto done;

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-10-19 16:41:30 UTC (rev 12048)
+++ tor/trunk/src/or/or.h	2007-10-19 16:41:32 UTC (rev 12049)
@@ -2919,7 +2919,8 @@
 int networkstatus_check_consensus_signature(networkstatus_vote_t *consensus,
                                             int warn);
 int networkstatus_add_detached_signatures(networkstatus_vote_t *target,
-                                          ns_detached_signatures_t *sigs);
+                                          ns_detached_signatures_t *sigs,
+                                          const char **msg_out);
 char *networkstatus_get_detached_signatures(networkstatus_vote_t *consensus);
 void ns_detached_signatures_free(ns_detached_signatures_t *s);
 

Modified: tor/trunk/src/or/test.c
===================================================================
--- tor/trunk/src/or/test.c	2007-10-19 16:41:30 UTC (rev 12048)
+++ tor/trunk/src/or/test.c	2007-10-19 16:41:32 UTC (rev 12049)
@@ -2757,6 +2757,7 @@
     networkstatus_vote_t *con2, *con3;
     char *detached_text1, *detached_text2;
     ns_detached_signatures_t *dsig1, *dsig2;
+    const char *msg=NULL;
     /* Compute the other two signed consensuses. */
     smartlist_shuffle(votes);
     consensus_text2 = networkstatus_compute_consensus(votes, 3,
@@ -2799,7 +2800,7 @@
 
     /* Try adding it to con2. */
     detached_text2 = networkstatus_get_detached_signatures(con2);
-    test_eq(1, networkstatus_add_detached_signatures(con2, dsig1));
+    test_eq(1, networkstatus_add_detached_signatures(con2, dsig1, &msg));
     tor_free(detached_text2);
     detached_text2 = networkstatus_get_detached_signatures(con2);
     //printf("\n<%s>\n", detached_text2);
@@ -2816,10 +2817,10 @@
     test_eq(2, smartlist_len(dsig2->signatures));
 
     /* Try adding to con2 twice; verify that nothing changes. */
-    test_eq(0, networkstatus_add_detached_signatures(con2, dsig1));
+    test_eq(0, networkstatus_add_detached_signatures(con2, dsig1, &msg));
 
     /* Add to con. */
-    test_eq(2, networkstatus_add_detached_signatures(con, dsig2));
+    test_eq(2, networkstatus_add_detached_signatures(con, dsig2, &msg));
     /* Check signatures */
     test_assert(!networkstatus_check_voter_signature(con,
                                                smartlist_get(con->voters, 0),