[Git][NTPsec/ntpsec][master] 2 commits: Cope with commas inside strings in control responses.

Eric S. Raymond gitlab at mg.gitlab.com
Sat Nov 26 20:05:35 UTC 2016


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


Commits:
5e5f8837 by Eric S. Raymond at 2016-11-26T14:53:02-05:00
Cope with commas inside strings in control responses.

- - - - -
9d95f6ee by Eric S. Raymond at 2016-11-26T15:05:15-05:00
Address GitLab issue #162: ntpq -p broken

- - - - -


1 changed file:

- pylib/packet.py


Changes:

=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -1014,7 +1014,7 @@ class ControlSession:
             not_earlier = [frag for frag in fragments \
                            if frag.offset >= rpkt.offset]
             if len(not_earlier):
-                not_earlier = earlier[0]
+                not_earlier = not_earlier[0]
                 if not_earlier.offset == rpkt.offset:
                     warn("duplicate %d octets at %d ignored, prior %d at %d\n" % (rpkt.count, rpkt.offset, not_earlier.count, not_earlier.offset))
                     continue
@@ -1102,12 +1102,18 @@ class ControlSession:
         response = response.rstrip()
         items = []
         if response:
+            instring = False
+            for i in range(len(response)):
+                if response[i] == '"':
+                    instring = not instring
+                elif instring and response[i] == ',':
+                    response[i] = "\xae"
             for pair in response.split(","):
                 try:
                     pair = pair.strip()
                     eq = pair.index("=")
                     var = pair[:eq].strip()
-                    val = pair[eq+1:].strip()
+                    val = pair[eq+1:].strip().replace("\xae", ",")
                     try:
                         val = int(val, 0)
                     except ValueError:



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/ca643ac749f8f042a9eb51f5ccb57c8bd9f5b845...9d95f6eecaa3bcede47cf98faf8b2b7ed6cff357
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161126/1fb940a1/attachment.html>


More information about the vc mailing list