]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2473] revisited: Avoid possible unsigned underrun for startup condition when...
authorJuergen Perlinger <perlinger@ntp.org>
Fri, 20 Sep 2013 11:40:43 +0000 (13:40 +0200)
committerJuergen Perlinger <perlinger@ntp.org>
Fri, 20 Sep 2013 11:40:43 +0000 (13:40 +0200)
bk: 523c343blTFb9GnJ9C43jv3f5ABwXA

ChangeLog
libntp/systime.c

index 10684a8789df611eb8ae6e443872247ab7fc50a8..fb364008844bba782e37936bd40a18ef3cda2900 100644 (file)
--- 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 <stenn@ntp.org>
 * [Bug 2473] NTPD exits after clock is stepped backwards externally
 (4.2.7p387) 2013/09/16 Released by Harlan Stenn <stenn@ntp.org>
index e8583c5439d5f96e796fccf3871cb1e35d7f3698..f5eabcd1c9fdd83e14d0ffd3a0963f0e4334b14e 100644 (file)
@@ -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;