]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 3394] Leap second deletion does not work on ntpd clients
authorJuergen Perlinger <perlinger@ntp.org>
Tue, 5 Sep 2017 06:40:47 +0000 (08:40 +0200)
committerJuergen Perlinger <perlinger@ntp.org>
Tue, 5 Sep 2017 06:40:47 +0000 (08:40 +0200)
bk: 59ae46efO1gOU5GtefrvwlPSz1esBQ

ChangeLog
ntpd/ntp_leapsec.c

index a1a1cfae45a59975bb12958d206f6c0a48e631b5..c2b39a9c3d9c0d7ffd08fbee98c98e4094686e91 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+---
+* [Bug 3394] Leap second deletion does not work on ntpd clients
+  - fixed handling of dynamic deletion w/o leap file <perlinger@ntp.org>
+  
 ---
 (4.2.8p10-win-beta1) 2017/03/21 Released by Harlan Stenn <stenn@ntp.org>
 (4.2.8p10)
index 7a652f5cf6b99c6a87aad045db634d1ce2bc7aae..95a06736751baa2665a2a5336fc78ad258365fa7 100644 (file)
@@ -743,14 +743,24 @@ add_range(
        const leap_info_t * pi)
 {
        /* If the table is full, make room by throwing out the oldest
-        * entry. But remember the accumulated leap seconds! Likewise,
-        * assume a positive leap insertion if this is the first entry
-        * in the table. This is not necessarily the best of all ideas,
-        * but it helps a great deal if a system does not have a leap
-        * table and gets updated from an upstream server.
+        * entry. But remember the accumulated leap seconds!
+        *
+        * Setting the first entry is a bit tricky, too: Simply assuming
+        * it is an insertion is wrong if the first entry is a dynamic
+        * leap second removal. So we decide on the sign -- if the first
+        * entry has a negative offset, we assume that it is a leap
+        * second removal. In both cases the table base offset is set
+        * accordingly to reflect the decision.
+        *
+        * In practice starting with a removal can only happen if the
+        * first entry is a dynamic request without having a leap file
+        * for the history proper.
         */
        if (pt->head.size == 0) {
-               pt->head.base_tai = pi->taiof - 1;
+               if (pi->taiof >= 0)
+                       pt->head.base_tai = pi->taiof - 1;
+               else
+                       pt->head.base_tai = pi->taiof + 1;
        } else if (pt->head.size >= MAX_HIST) {
                pt->head.size     = MAX_HIST - 1;
                pt->head.base_tai = pt->info[pt->head.size].taiof;