]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
sourcestats: don't load samples from future
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 18 May 2022 14:30:19 +0000 (16:30 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 18 May 2022 14:38:41 +0000 (16:38 +0200)
When loading a dumped file, make sure there are no sample times in
future relative to the current system time (e.g. after reboot with
missing RTC).

sourcestats.c

index ef64bf8c7591e3fc071ead7d63b31935dad23f3a..eb4705ecd3b1ae76f67e28e63a253ebf8e1e8eec 100644 (file)
@@ -931,6 +931,7 @@ SST_LoadFromFile(SST_Stats inst, FILE *in)
 
     /* Make sure the samples are sane and they are in order */
     if (!UTI_IsTimeOffsetSane(&inst->sample_times[i], -inst->offsets[i]) ||
+        UTI_CompareTimespecs(&now, &inst->sample_times[i]) < 0 ||
         !(fabs(inst->peer_delays[i]) < 1.0e6 && fabs(inst->peer_dispersions[i]) < 1.0e6 &&
           fabs(inst->root_delays[i]) < 1.0e6 && fabs(inst->root_dispersions[i]) < 1.0e6) ||
         (i > 0 && UTI_CompareTimespecs(&inst->sample_times[i],