]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
prop224: Improve our checks for unset HSDir index.
authorGeorge Kadianakis <desnacked@riseup.net>
Sat, 12 Aug 2017 10:05:25 +0000 (13:05 +0300)
committerGeorge Kadianakis <desnacked@riseup.net>
Sat, 19 Aug 2017 13:28:43 +0000 (16:28 +0300)
We used to not check next hsdir index.

src/or/hs_common.c

index 6c860b0cf0eb17d771ef783a92716c33d7a89abb..0529c0cdb0db2932836953c88b92bab4b4ff90f2 100644 (file)
@@ -1180,9 +1180,10 @@ hs_get_hsdir_spread_store(void)
 }
 
 /** <b>node</b> is an HSDir so make sure that we have assigned an hsdir index.
+ *  If <b>is_for_next_period</b> is set, also check the next HSDir index field.
  *  Return 0 if everything is as expected, else return -1. */
 static int
-node_has_hsdir_index(const node_t *node)
+node_has_hsdir_index(const node_t *node, int is_for_next_period)
 {
   tor_assert(node_supports_v3_hsdir(node));
 
@@ -1200,6 +1201,12 @@ node_has_hsdir_index(const node_t *node)
     return 0;
   }
 
+  if (is_for_next_period &&
+      BUG(tor_mem_is_zero((const char*)node->hsdir_index->next,
+                          DIGEST256_LEN))) {
+    return 0;
+  }
+
   return 1;
 }
 
@@ -1244,7 +1251,7 @@ hs_get_responsible_hsdirs(const ed25519_public_key_t *blinded_pk,
       node_t *n = node_get_mutable_by_id(rs->identity_digest);
       tor_assert(n);
       if (node_supports_v3_hsdir(n) && rs->is_hs_dir) {
-        if (!node_has_hsdir_index(n)) {
+        if (!node_has_hsdir_index(n, is_next_period)) {
           log_info(LD_GENERAL, "Node %s was found without hsdir index.",
                    node_describe(n));
           continue;