Parcourir la source

Make nodelist_purge avoid orphaned microdescs in rs-less nodes

We have an invariant that a node_t should have an md only if it has
a routerstatus.  nodelist_purge tried to preserve this by removing
all nodes without a routerstatus or a routerinfo.  But this left
nodes with a routerinfo and a microdesc untouched, even if they had
a routerstatus.

Bug found by frosty_un.
Nick Mathewson il y a 14 ans
Parent
commit
a4d339cf08
1 fichiers modifiés avec 6 ajouts et 0 suppressions
  1. 6 0
      src/or/nodelist.c

+ 6 - 0
src/or/nodelist.c

@@ -317,6 +317,12 @@ nodelist_purge(void)
   for (iter = HT_START(nodelist_map, &the_nodelist->nodes_by_id); iter; ) {
     node_t *node = *iter;
 
+    if (node->md && !node->rs) {
+      /* An md is only useful if there is an rs. */
+      node->md->held_by_node = 0;
+      node->md = NULL;
+    }
+
     if (node_is_usable(node)) {
       iter = HT_NEXT(nodelist_map, &the_nodelist->nodes_by_id, iter);
     } else {