From: Juergen Perlinger Date: Sat, 27 Apr 2019 16:55:23 +0000 (+0200) Subject: [Bug 3583] synchronization error X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01dc26f3785ed8c7ff3f5332d194a68045cb0a57;p=thirdparty%2Fntp.git [Bug 3583] synchronization error bk: 5cc4897bbO_nj6Pn9x6u8uCrywhN-w --- diff --git a/ChangeLog b/ChangeLog index 9ff845c81..1343d7859 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +--- +* [Bug 3583] synchronization error + - set clock to base date if system time is before that limit + --- (4.2.8p13) 2019/03/07 Released by Harlan Stenn diff --git a/libntp/systime.c b/libntp/systime.c index 8e7089746..a738c8d92 100644 --- a/libntp/systime.c +++ b/libntp/systime.c @@ -619,12 +619,11 @@ clamp_systime(void) { #if SIZEOF_TIME_T > 4 - struct timeval timetv, tvlast; + struct timeval tvbase, tvlast; struct timespec timets; - uint32_t tdiff; - - timetv.tv_sec = basedate_get_erabase(); + tvbase.tv_sec = basedate_get_erabase(); + tvbase.tv_usec = 0; /* ---> time-critical path starts ---> */ @@ -636,28 +635,24 @@ clamp_systime(void) tvlast.tv_usec -= 1000000; tvlast.tv_sec += 1; } - timetv.tv_usec = tvlast.tv_usec; - tdiff = (uint32_t)(tvlast.tv_sec & UINT32_MAX) - - (uint32_t)(timetv.tv_sec & UINT32_MAX); - timetv.tv_sec += tdiff; - if (timetv.tv_sec != tvlast.tv_sec) { + if (tvbase.tv_sec > tvlast.tv_sec) { /* now set new system time */ - if (ntp_set_tod(&timetv, NULL) != 0) { + if (ntp_set_tod(&tvbase, NULL) != 0) { msyslog(LOG_ERR, "clamp-systime: %m"); return FALSE; } } else { msyslog(LOG_INFO, "clamp-systime: clock (%s) in allowed range", - tv_fmt_libbuf(&timetv)); + tv_fmt_libbuf(&tvlast)); return FALSE; } /* <--- time-critical path ended with 'ntp_set_tod()' <--- */ sys_residual = 0; - lamport_violated = (timetv.tv_sec < tvlast.tv_sec); + lamport_violated = (tvbase.tv_sec < tvlast.tv_sec); if (step_callback) (*step_callback)(); @@ -668,15 +663,16 @@ clamp_systime(void) _clear_adjtime(); # endif - update_uwtmp(timetv, tvlast); + update_uwtmp(tvbase, tvlast); msyslog(LOG_WARNING, "clamp-systime: clock stepped from %s to %s!", - tv_fmt_libbuf(&tvlast), tv_fmt_libbuf(&timetv)); + tv_fmt_libbuf(&tvlast), tv_fmt_libbuf(&tvbase)); return TRUE; #else - return 0; + return FALSE; + #endif }