Browse Source

Merge remote branch 'origin/maint-0.2.2'

Conflicts:
	src/or/networkstatus.c
Nick Mathewson 15 years ago
parent
commit
444193ff5d
4 changed files with 23 additions and 8 deletions
  1. 5 0
      changes/caches_if_exit
  2. 4 0
      changes/set_ns_crash
  3. 1 1
      src/or/dirserv.c
  4. 13 7
      src/or/networkstatus.c

+ 5 - 0
changes/caches_if_exit

@@ -0,0 +1,5 @@
+  o Minor bugfixes:
+    - Fix a logic error where servers that _didn't_ act as exits would
+      try to keep their server lists more aggressively up to date than
+      exits, when it was supposed to be the other way around. Bugfix
+      on 0.2.2.17-alpha.

+ 4 - 0
changes/set_ns_crash

@@ -0,0 +1,4 @@
+  o Major bugfixes:
+    - Avoid a crash bug triggered by looking at a dangling pointer while
+      setting the network status consensus. Found by Robert Ransom.
+      Bugfix on 0.2.2.17-alpha.  Fixes bug 2097.

+ 1 - 1
src/or/dirserv.c

@@ -1238,7 +1238,7 @@ directory_caches_dir_info(or_options_t *options)
     return 0;
   /* We need an up-to-date view of network info if we're going to try to
    * block exit attempts from unknown relays. */
-  return router_my_exit_policy_is_reject_star() &&
+  return ! router_my_exit_policy_is_reject_star() &&
     should_refuse_unknown_exits(options);
 }
 

+ 13 - 7
src/or/networkstatus.c

@@ -1739,6 +1739,10 @@ networkstatus_set_current_consensus(const char *consensus,
     if (current_ns_consensus) {
       networkstatus_copy_old_consensus_info(c, current_ns_consensus);
       networkstatus_vote_free(current_ns_consensus);
+      /* Defensive programming : we should set current_consensus very soon,
+       * but we're about to call some stuff in the meantime, and leaving this
+       * dangling pointer around has proven to be trouble. */
+      current_ns_consensus = NULL;
     }
     current_ns_consensus = c;
     free_consensus = 0; /* avoid free */
@@ -1746,6 +1750,8 @@ networkstatus_set_current_consensus(const char *consensus,
     if (current_md_consensus) {
       networkstatus_copy_old_consensus_info(c, current_md_consensus);
       networkstatus_vote_free(current_md_consensus);
+      /* more defensive programming */
+      current_md_consensus = NULL;
     }
     current_md_consensus = c;
     free_consensus = 0; /* avoid free */
@@ -1773,13 +1779,6 @@ networkstatus_set_current_consensus(const char *consensus,
       download_status_failed(&consensus_dl_status[flav], 0);
   }
 
-  if (directory_caches_dir_info(options)) {
-    dirserv_set_cached_consensus_networkstatus(consensus,
-                                               flavor,
-                                               &c->digests,
-                                               c->valid_after);
-  }
-
   if (flav == USABLE_CONSENSUS_FLAVOR) {
     /* XXXXNM Microdescs: needs a non-ns variant. */
     update_consensus_networkstatus_fetch_time(now);
@@ -1796,6 +1795,13 @@ networkstatus_set_current_consensus(const char *consensus,
     circuit_build_times_new_consensus_params(&circ_times, current_consensus);
   }
 
+  if (directory_caches_dir_info(options)) {
+    dirserv_set_cached_consensus_networkstatus(consensus,
+                                               flavor,
+                                               &c->digests,
+                                               c->valid_after);
+  }
+
   if (!from_cache) {
     write_str_to_file(consensus_fname, consensus, 0);
   }