]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Avoid assertion failure for state file clock skew
authorTaylor Yu <catalyst@torproject.org>
Wed, 20 Sep 2017 23:47:15 +0000 (18:47 -0500)
committerTaylor Yu <catalyst@torproject.org>
Wed, 20 Sep 2017 23:54:37 +0000 (18:54 -0500)
The clock_skew_warning() refactoring allowed calls from
or_state_load() to control_event_bootstrap_problem() to occur prior
bootstrap phase 0, causing an assertion failure.  Initialize the
bootstrap status prior to calling clock_skew_warning() from
or_state_load().

changes/bug23607 [new file with mode: 0644]
src/or/statefile.c

diff --git a/changes/bug23607 b/changes/bug23607
new file mode 100644 (file)
index 0000000..7aa48a9
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor bugfixes (bootstrapping):
+    - Avoid an assertion failure when logging a state file clock skew
+      very early in bootstrapping.  Fixes bug 23607; bugfix on
+      0.3.2.1-alpha.
index 86f26419befad1f0bbfe64494a1708f49ea49dd8..2d579a022037e554291a41c518fdecbb69d2f214 100644 (file)
@@ -34,6 +34,7 @@
 #include "config.h"
 #include "confparse.h"
 #include "connection.h"
+#include "control.h"
 #include "entrynodes.h"
 #include "hibernate.h"
 #include "rephist.h"
@@ -405,9 +406,14 @@ or_state_load(void)
     /* Warn the user if their clock has been set backwards,
      * they could be tricked into using old consensuses */
     time_t apparent_skew = time(NULL) - new_state->LastWritten;
-    if (apparent_skew < 0)
+    if (apparent_skew < 0) {
+      /* Initialize bootstrap event reporting because we might call
+       * clock_skew_warning() before the bootstrap state is
+       * initialized, causing an asserttion failure. */
+      control_event_bootstrap(BOOTSTRAP_STATUS_STARTING, 0);
       clock_skew_warning(NULL, (long)apparent_skew, 1, LD_GENERAL,
                          "local state file", fname);
+    }
   } else {
     log_info(LD_GENERAL, "Initialized state");
   }