From: Juergen Perlinger Date: Fri, 20 Sep 2013 11:40:43 +0000 (+0200) Subject: [Bug 2473] revisited: Avoid possible unsigned underrun for startup condition when... X-Git-Tag: NTP_4_2_7P389~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a534829e26cf8abe3f5e0da2dc6be8cb72cef03;p=thirdparty%2Fntp.git [Bug 2473] revisited: Avoid possible unsigned underrun for startup condition when testing for clock backstep. bk: 523c343blTFb9GnJ9C43jv3f5ABwXA --- diff --git a/ChangeLog b/ChangeLog index 10684a878..fb3640088 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +* [Bug 2473] revisited: NTPD exits after clock is stepped backwards + Avoid possible unsigned underrun for startup condition when testing + for clock backstep. (4.2.7p388) 2013/09/19 Released by Harlan Stenn * [Bug 2473] NTPD exits after clock is stepped backwards externally (4.2.7p387) 2013/09/16 Released by Harlan Stenn diff --git a/libntp/systime.c b/libntp/systime.c index e8583c543..f5eabcd1c 100644 --- a/libntp/systime.c +++ b/libntp/systime.c @@ -76,6 +76,11 @@ int trunc_os_clock; /* sys_tick > measured_tick */ time_stepped_callback step_callback; #ifndef SIM +/* perlinger@ntp.org: As 'get_sysime()' does it's own check for clock + * backstepping, this could probably become a local variable in + * 'get_systime()' and the cruft associated with communicating via a + * static value could be removed after the v4.2.8 release. + */ static int lamport_violated; /* clock was stepped back */ #endif /* !SIM */ @@ -179,9 +184,12 @@ get_systime( /* First check if here was a Lamport violation, that is, two * successive calls to 'get_ostime()' resulted in negative * time difference. Use a few milliseconds of permissible - * tolerance -- being too sharp can hurt here. + * tolerance -- being too sharp can hurt here. (This is intented + * for the Win32 target, where the HPC interpolation might + * introduce small steps backward. It should not be an issue on + * systems where get_ostime() results in a true syscall.) */ - if (cmp_tspec(ts, sub_tspec_ns(ts_last, 50000000)) < 0) + if (cmp_tspec(add_tspec_ns(ts, 50000000), ts_last) < 0) lamport_violated = 1; ts_last = ts;