]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
refclock: check offset sanity
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 7 Apr 2015 13:02:32 +0000 (15:02 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Tue, 7 Apr 2015 13:23:47 +0000 (15:23 +0200)
refclock.c

index 59e9297244cdbb72556bec66f1a9b82b2e6d47d0..81a3e99bc0d719a9d05beb527bebbf5a749ac7f4 100644 (file)
@@ -367,7 +367,9 @@ RCL_AddSample(RCL_Instance instance, struct timeval *sample_time, double offset,
   UTI_AddDoubleToTimeval(sample_time, correction, &cooked_time);
   dispersion += instance->precision;
 
-  if (!valid_sample_time(instance, sample_time))
+  /* Make sure the timestamp and offset provided by the driver are sane */
+  if (!UTI_IsTimeOffsetSane(sample_time, offset) ||
+      !valid_sample_time(instance, sample_time))
     return 0;
 
   filter_add_sample(&instance->filter, &cooked_time, offset - correction + instance->offset, dispersion);
@@ -407,7 +409,8 @@ RCL_AddPulse(RCL_Instance instance, struct timeval *pulse_time, double second)
   UTI_AddDoubleToTimeval(pulse_time, correction, &cooked_time);
   dispersion += instance->precision;
 
-  if (!valid_sample_time(instance, pulse_time))
+  if (!UTI_IsTimeOffsetSane(pulse_time, 0.0) ||
+      !valid_sample_time(instance, pulse_time))
     return 0;
 
   rate = instance->pps_rate;