[Git][NTPsec/ntpsec][master] Replaced magic number for keyid with MAX_KEYID

Ian Bruene gitlab at mg.gitlab.com
Fri Aug 25 22:34:05 UTC 2017


Ian Bruene pushed to branch master at NTPsec / ntpsec


Commits:
acde54c3 by Ian Bruene at 2017-08-25T17:33:03-05:00
Replaced magic number for keyid with MAX_KEYID

- - - - -


1 changed file:

- pylib/packet.py


Changes:

=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -327,6 +327,8 @@ MAXFRAGS = 32
 DEFTIMEOUT = 5000
 DEFSTIMEOUT = 3000
 
+# The maximum keyid for authentication, keyid is a 16-bit field
+MAX_KEYID = 0xFFFF
 
 class Packet:
     "Encapsulate an NTP fragment"
@@ -911,7 +913,7 @@ class ControlSession:
             try:
                 key_id = int(input("Keyid: "))
                 # FIXME: Magic number, yuck
-                if key_id == 0 or key_id > 65535:
+                if key_id == 0 or key_id > MAX_KEYID:
                     raise ControlException(SERR_BADKEY)
             except (SyntaxError, ValueError):
                 raise ControlException(SERR_BADKEY)



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/acde54c37b0407e70f2a3329b1616aab128bac86

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/acde54c37b0407e70f2a3329b1616aab128bac86
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170825/1f171aa4/attachment.html>


More information about the vc mailing list