[Git][NTPsec/ntpsec][master] Correct leap-second extraction.

Eric S. Raymond gitlab at mg.gitlab.com
Sun Nov 13 00:25:27 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
83dd0c5a by Eric S. Raymond at 2016-11-12T19:24:58-05:00
Correct leap-second extraction.

- - - - -


2 changed files:

- ntpdig/pyntpdig
- pylib/packet.py


Changes:

=====================================
ntpdig/pyntpdig
=====================================
--- a/ntpdig/pyntpdig
+++ b/ntpdig/pyntpdig
@@ -103,7 +103,7 @@ class SNTPPacket:
         # FIXME: Clip low digits according to precision
         return self.received - self.transmit_timestamp
     def leap(self):
-        return ("no-leap", "add-leap", "del-leap", "unsync")[(self.livnm & 0x60) >> 6]
+        return ("no-leap", "add-leap", "del-leap", "unsync")[((self.livnm) >> 6) & 0x3]
 
 def queryhost(server, concurrent, timeout=5, port=123):
     "Query IP addresses associated with a specified host."
@@ -195,13 +195,13 @@ def clock_select(packets):
             drop("stratum too high")
             continue
         if server.leap() == "unsync":
-            drop("Leap not in sync")
+            drop("leap not in sync")
             continue
         if not server.origin_timestamp < server.reference_timestamp:
             drop("server is very broken")
             continue
         if server.origin_timestamp - server.reference_timestamp >= NTP_MAXAGE:
-            drop("Server has gone too long without sync")
+            drop("server has gone too long without sync")
             continue
         if not server.trusted:
             drop("request was authenticated but server is untrusted")


=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -245,7 +245,7 @@ class Packet:
         self.__extension = polybytes(x)
 
     def leap(self):
-        return ("no-leap", "add-leap", "del-leap", "unsync")[(self.li_vn_mode & 0x60) >> 6]
+        return ("no-leap", "add-leap", "del-leap", "unsync")[PKT_LEAP(self.li_vn_mode)]
 
     def version(self):
         return (self.li_vn_mode >> 3) & 0x7



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/83dd0c5a46166ba66411e2fc934b6153c795cb54
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161113/3e8a5206/attachment.html>


More information about the vc mailing list