]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: limit total monotonic offset correction
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 2 Dec 2021 09:56:26 +0000 (10:56 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 2 Dec 2021 10:01:01 +0000 (11:01 +0100)
In addition to the 16s limit in per-response change in the monotonic
offset, don't allow the total accumulated offset injected in sourcestats
to be larger than 16 seconds.

ntp_core.c

index 6c3ba760c719840e1c4a486cd92e59fb02e394fd..f259f6a5f89e355a2a55623890357467f3516b10 100644 (file)
@@ -1660,11 +1660,11 @@ process_sample(NCR_Instance inst, NTP_Sample *sample)
 
   error_in_estimate = fabs(-sample->offset - estimated_offset);
 
-  if (inst->mono_doffset != 0.0) {
+  if (inst->mono_doffset != 0.0 && fabs(inst->mono_doffset) <= MAX_MONO_DOFFSET) {
     DEBUG_LOG("Monotonic correction offset=%.9f", inst->mono_doffset);
     SST_CorrectOffset(SRC_GetSourcestats(inst->source), inst->mono_doffset);
-    inst->mono_doffset = 0.0;
   }
+  inst->mono_doffset = 0.0;
 
   SRC_AccumulateSample(inst->source, sample);
   SRC_SelectSource(inst->source);