]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
increase IPv4 parsing strictness yet more
authorBob Halley <halley@nominum.com>
Wed, 13 Jul 2011 00:56:56 +0000 (17:56 -0700)
committerBob Halley <halley@nominum.com>
Wed, 13 Jul 2011 00:56:56 +0000 (17:56 -0700)
dns/ipv4.py

index ec7d2d24699b8b8e4c555d9d9a133568f2960bb6..e117966e5fbe1d5ae2cba5f8967364e0b8a7ab0b 100644 (file)
@@ -29,6 +29,12 @@ def inet_aton(text):
     parts = text.split('.')
     if len(parts) != 4:
         raise dns.exception.SyntaxError
+    for part in parts:
+        if not part.isdigit():
+            raise dns.exception.SyntaxError
+        if len(part) > 1 and part[0] == '0':
+            # No leading zeros
+            raise dns.exception.SyntaxError
     try:
         bytes = [int(part) for part in parts]
         return struct.pack('BBBB', *bytes)