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

index 1860ddcb0d160000c084421f5d2404b460c2c4c6..f3b6c5c550a71ad8691355934bae32ddb044d273 100644 (file)
@@ -28,6 +28,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)