[or-cvs] [tor/master 05/17] Clearly mark directory footer so we parse the new weight line.

nickm at torproject.org nickm at torproject.org
Thu Feb 25 21:25:11 UTC 2010


Author: Mike Perry <mikeperry-git at fscked.org>
Date: Sun, 14 Feb 2010 17:49:08 -0800
Subject: Clearly mark directory footer so we parse the new weight line.
Commit: 87a0430a74800ced173bd83215921101b3ac3653

---
 src/or/dirvote.c     |   10 ++++++++++
 src/or/routerparse.c |   16 ++++++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index 143c324..ca75fb7 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -111,6 +111,7 @@ format_networkstatus_vote(crypto_pk_env_t *private_signing_key,
   len = 8192;
   len += strlen(version_lines);
   len += (RS_ENTRY_LEN+MICRODESC_LINE_LEN)*smartlist_len(rl->routers);
+  len += strlen("\ndirectory-footer\n");
   len += v3_ns->cert->cache_info.signed_descriptor_len;
 
   status = tor_malloc(len);
@@ -199,6 +200,9 @@ format_networkstatus_vote(crypto_pk_env_t *private_signing_key,
     }
   } SMARTLIST_FOREACH_END(vrs);
 
+  tor_snprintf(outp, endp-outp, "directory-footer\n");
+  outp += strlen(outp);
+
   {
     char signing_key_fingerprint[FINGERPRINT_LEN+1];
     if (tor_snprintf(outp, endp-outp, "directory-signature ")<0) {
@@ -1673,6 +1677,12 @@ networkstatus_compute_consensus(smartlist_t *votes,
   }
 
   if (consensus_method >= 9) {
+    /* Starting with consensus method 9, we clearly mark the directory
+     * footer region */
+    smartlist_add(chunks, tor_strdup("directory-footer\n"));
+  }
+
+  if (consensus_method >= 9) {
     int64_t weight_scale = BW_WEIGHT_SCALE;
     char *bw_weight_param = NULL;
 
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 1212907..082bf2e 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -1870,22 +1870,30 @@ authority_cert_parse_from_string(const char *s, const char **end_of_string)
 
 /** Helper: given a string <b>s</b>, return the start of the next router-status
  * object (starting with "r " at the start of a line).  If none is found,
- * return the start of the next directory signature.  If none is found, return
- * the end of the string. */
+ * return the start of the directory footer, or the next directory signature.
+ * If none is found, return the end of the string. */
 static INLINE const char *
 find_start_of_next_routerstatus(const char *s)
 {
   const char *eos = strstr(s, "\nr ");
   if (eos) {
-    const char *eos2 = tor_memstr(s, eos-s, "\ndirectory-signature");
+    const char *eos2 = tor_memstr(s, eos-s, "\ndirectory-footer\n");
+    if (eos2) eos2 += strlen("\ndirectory-footer");
+    else eos2 = tor_memstr(s, eos-s, "\ndirectory-signature");
+    /* Technically we are returning either the start of the next
+     * routerstatus AFTER the \n, or the start of the next consensus
+     * line AT the \n. This seems asymmetric, but leaving it that way
+     * for now for stability. */
     if (eos2 && eos2 < eos)
       return eos2;
     else
       return eos+1;
   } else {
+    if ((eos = strstr(s, "\ndirectory-footer\n")))
+      return eos+strlen("\ndirectory-footer\n");
     if ((eos = strstr(s, "\ndirectory-signature")))
       return eos+1;
-    return s + strlen(s);
+     return s + strlen(s);
   }
 }
 
-- 
1.6.5




More information about the tor-commits mailing list