]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
r11970@catbus: nickm | 2007-02-27 19:17:27 -0500
authorNick Mathewson <nickm@torproject.org>
Wed, 28 Feb 2007 00:23:05 +0000 (00:23 +0000)
committerNick Mathewson <nickm@torproject.org>
Wed, 28 Feb 2007 00:23:05 +0000 (00:23 +0000)
 Fix a bug found by Udo van den Heuvel: avoid an assertion failure when a controller sets and clears EntryNodes before the next call to choose_random_entry().  Also make a function static.

svn:r9669

ChangeLog
src/or/circuitbuild.c
src/or/or.h

index 304de677b71c2d808653fd642ef5ae91b1b6abe3..e0b83927c3db2ae72e7bda590721ddd20293424e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,10 @@ Changes in version 0.1.2.9-??? - 2007-??-??
     - Do not rotate onion key immediately after setting it for the first
       time.
 
+  o Minor bugfixes (other):
+    - Fix an assert that could trigger if a controller quickly set then
+      cleared EntryNodes.  (Bug found by Udo van den Heuvel.)
+
 
 Changes in version 0.1.2.8-beta - 2007-02-26
   o Major bugfixes (crashes):
index bddb22e4d02e38fd31f71b6207112a42dd4589da..f33074783e8f943cfdd7235e355bf931d09df779 100644 (file)
@@ -2251,7 +2251,7 @@ entry_nodes_should_be_added(void)
 
 /** Add all nodes in EntryNodes that aren't currently guard nodes to the list
  * of guard nodes, at the front. */
-void
+static void
 entry_guards_prepend_from_config(void)
 {
   or_options_t *options = get_options();
@@ -2259,9 +2259,17 @@ entry_guards_prepend_from_config(void)
   smartlist_t *old_entry_guards_on_list = smartlist_create();
   smartlist_t *old_entry_guards_not_on_list = smartlist_create();
   smartlist_t *entry_fps = smartlist_create();
-
   tor_assert(entry_guards);
-  tor_assert(options->EntryNodes);
+
+  should_add_entry_nodes = 0;
+
+  if (!options->EntryNodes) {
+    /* It's possible that a controller set EntryNodes, thus making
+     * should_add_entry_nodes set, then cleared it again, all before the
+     * call to choose_random_entry() that triggered us. If so, just return.
+     */
+    return;
+  }
 
   log_info(LD_CIRC,"Adding configured EntryNodes '%s'.",
            options->EntryNodes);
@@ -2300,7 +2308,6 @@ entry_guards_prepend_from_config(void)
     smartlist_add_all(entry_guards, old_entry_guards_not_on_list);
   }
 
-  should_add_entry_nodes = 0;
   smartlist_free(entry_routers);
   smartlist_free(entry_fps);
   smartlist_free(old_entry_guards_on_list);
index 960c6ef6250a7a746060d6799023c9d2332e229d..3820102847a700b433a9151aa250772dabc2b34c 100644 (file)
@@ -1980,7 +1980,6 @@ void entry_guards_compute_status(void);
 int entry_guard_register_connect_status(const char *digest, int succeeded,
                                         time_t now);
 void entry_nodes_should_be_added(void);
-void entry_guards_prepend_from_config(void);
 void entry_guards_update_state(or_state_t *state);
 int entry_guards_parse_state(or_state_t *state, int set, char **msg);
 int getinfo_helper_entry_guards(control_connection_t *conn,