]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
reference: check for unset leap_when in is_leap_close()
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 1 Dec 2021 08:14:34 +0000 (09:14 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 1 Dec 2021 08:22:26 +0000 (09:22 +0100)
Check that the leap_when variable is set before testing a timestamp for
being close to a leap second. This allows the first measurement to be
accepted if starting at the Unix epoch (e.g. in a test).

reference.c

index bf30991613c90caf210914771fc8edf77dc46a18..903232305acbc44c811fbbf8cacdaecc55705fea 100644 (file)
@@ -1333,7 +1333,8 @@ REF_DisableLocal(void)
 static int
 is_leap_close(time_t t)
 {
-  return t >= leap_when - LEAP_SECOND_CLOSE && t < leap_when + LEAP_SECOND_CLOSE;
+  return leap_when != 0 &&
+         t >= leap_when - LEAP_SECOND_CLOSE && t < leap_when + LEAP_SECOND_CLOSE;
 }
 
 /* ================================================== */