]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use correct sign for state file clock skew
authorTaylor Yu <catalyst@torproject.org>
Wed, 20 Sep 2017 21:54:56 +0000 (16:54 -0500)
committerTaylor Yu <catalyst@torproject.org>
Wed, 20 Sep 2017 23:50:39 +0000 (18:50 -0500)
or_state_load() was using an incorrect sign convention when calling
clock_skew_warning() to warn about state file clock skew.  This caused
the wording of the warning to be incorrect about the direction of the
skew.

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

diff --git a/changes/bug23606 b/changes/bug23606
new file mode 100644 (file)
index 0000000..77f4d0c
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor bugfixes (bootstrapping):
+    - When warning about state file clock skew, report the correct
+      direction for the detected skew.  Fixes bug 23606; bugfix on
+      0.2.8.1-alpha.
index 9647aa88342f37686cd30eda6676b0db9b4b95ca..86f26419befad1f0bbfe64494a1708f49ea49dd8 100644 (file)
@@ -404,8 +404,8 @@ or_state_load(void)
     log_info(LD_GENERAL, "Loaded state from \"%s\"", fname);
     /* Warn the user if their clock has been set backwards,
      * they could be tricked into using old consensuses */
-    time_t apparent_skew = new_state->LastWritten - time(NULL);
-    if (apparent_skew > 0)
+    time_t apparent_skew = time(NULL) - new_state->LastWritten;
+    if (apparent_skew < 0)
       clock_skew_warning(NULL, (long)apparent_skew, 1, LD_GENERAL,
                          "local state file", fname);
   } else {