From: Bob Halley Date: Wed, 13 Jul 2011 00:57:21 +0000 (-0700) Subject: increase IPv4 parsing strictness yet more X-Git-Tag: v1.10.0-py3~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=490083eebe545d753089f9ec90957d5ec68a4e45;p=thirdparty%2Fdnspython.git increase IPv4 parsing strictness yet more --- diff --git a/dns/ipv4.py b/dns/ipv4.py index 1860ddcb..f3b6c5c5 100644 --- a/dns/ipv4.py +++ b/dns/ipv4.py @@ -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)