[Git][NTPsec/ntpsec][master] Fixed problem with assocAddr handler dying on ipv6 hex-strings.

Ian Bruene gitlab at mg.gitlab.com
Sun Jan 7 16:37:48 UTC 2018


Ian Bruene pushed to branch master at NTPsec / ntpsec


Commits:
fa5b74ae by Ian Bruene at 2018-01-07T10:36:47-06:00
Fixed problem with assocAddr handler dying on ipv6 hex-strings.

- - - - -


1 changed file:

- ntpclients/ntpsnmpd.py


Changes:

=====================================
ntpclients/ntpsnmpd.py
=====================================
--- a/ntpclients/ntpsnmpd.py
+++ b/ntpclients/ntpsnmpd.py
@@ -662,21 +662,22 @@ class DataSource:  # This will be broken up in future to be less NTP-specific
                 addr = None  # how to handle?
                 ipv6 = None
             # Convert address string to octets
+            srcadr = []
             if ipv6 is False:
                 pieces = addr.split(".")
+                for piece in pieces:
+                    try:
+                        srcadr.append(int(piece))  # feed it a list of ints
+                    except ValueError:
+                        # Have gotten piece == "" before. Skip over that.
+                        # Still try to return data because it is potential
+                        # debugging information.
+                        continue
             elif ipv6 is True:
                 pieces = addr.split(":")
-            else:
-                pieces = []
-            srcadr = []
-            for x in pieces:
-                try:
-                    srcadr.append(int(x))
-                except ValueError:
-                    # Have gotten x == "" before. Skip over.
-                    # Still try to return data because it is potential
-                    # debugging information.
-                    pass
+                for piece in pieces:
+                    srcadr.append(ntp.util.hexstr2octets(piece))
+                srcadr = "".join(srcadr)  # feed it an octet string
             return ax.Varbind(ax.VALUE_OCTET_STR, oid, srcadr)
         return self.dynamicCallbackSkeleton(handler)
 



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

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/fa5b74ae5cc92abde0fc0bef7c3a7c10b3e1da64
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/20180107/354f994e/attachment.html>


More information about the vc mailing list