[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Use correct sign for state file clock skew



commit 1c017edac369a40c9a1633b0560e5f0d85b4e39e
Author: Taylor Yu <catalyst@xxxxxxxxxxxxxx>
Date:   Wed Sep 20 16:54:56 2017 -0500

    Use correct sign for state file clock skew
    
    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   | 4 ++++
 src/or/statefile.c | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/changes/bug23606 b/changes/bug23606
new file mode 100644
index 000000000..77f4d0cb9
--- /dev/null
+++ b/changes/bug23606
@@ -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.
diff --git a/src/or/statefile.c b/src/or/statefile.c
index 9647aa883..86f26419b 100644
--- a/src/or/statefile.c
+++ b/src/or/statefile.c
@@ -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 {



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits