Merge remote-tracking branch 'catalyst-oniongit/bug23607'

This commit is contained in:
Nick Mathewson 2017-09-21 10:58:06 -04:00
commit 4c7a89a226
3 changed files with 16 additions and 2 deletions

4
changes/bug23606 Normal file
View File

@ -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.

4
changes/bug23607 Normal file
View File

@ -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.

View File

@ -34,6 +34,7 @@
#include "config.h" #include "config.h"
#include "confparse.h" #include "confparse.h"
#include "connection.h" #include "connection.h"
#include "control.h"
#include "entrynodes.h" #include "entrynodes.h"
#include "hibernate.h" #include "hibernate.h"
#include "rephist.h" #include "rephist.h"
@ -404,10 +405,15 @@ or_state_load(void)
log_info(LD_GENERAL, "Loaded state from \"%s\"", fname); log_info(LD_GENERAL, "Loaded state from \"%s\"", fname);
/* Warn the user if their clock has been set backwards, /* Warn the user if their clock has been set backwards,
* they could be tricked into using old consensuses */ * they could be tricked into using old consensuses */
time_t apparent_skew = new_state->LastWritten - time(NULL); 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, clock_skew_warning(NULL, (long)apparent_skew, 1, LD_GENERAL,
"local state file", fname); "local state file", fname);
}
} else { } else {
log_info(LD_GENERAL, "Initialized state"); log_info(LD_GENERAL, "Initialized state");
} }