From: Miroslav Lichvar Date: Tue, 7 Apr 2015 13:02:32 +0000 (+0200) Subject: refclock: check offset sanity X-Git-Tag: 2.0-pre2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42774ee8510fa4d71e6b0db30fdf8a51b88a26b9;p=thirdparty%2Fchrony.git refclock: check offset sanity --- diff --git a/refclock.c b/refclock.c index 59e92972..81a3e99b 100644 --- a/refclock.c +++ b/refclock.c @@ -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;