From: Juergen Perlinger Date: Tue, 5 Sep 2017 06:40:47 +0000 (+0200) Subject: [Bug 3394] Leap second deletion does not work on ntpd clients X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e26058dc2d21c8b350034511e620e82c7793819;p=thirdparty%2Fntp.git [Bug 3394] Leap second deletion does not work on ntpd clients bk: 59ae46efO1gOU5GtefrvwlPSz1esBQ --- diff --git a/ChangeLog b/ChangeLog index a1a1cfae4..c2b39a9c3 100644 --- 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 + --- (4.2.8p10-win-beta1) 2017/03/21 Released by Harlan Stenn (4.2.8p10) diff --git a/ntpd/ntp_leapsec.c b/ntpd/ntp_leapsec.c index 7a652f5cf..95a067367 100644 --- a/ntpd/ntp_leapsec.c +++ b/ntpd/ntp_leapsec.c @@ -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;