From 490083eebe545d753089f9ec90957d5ec68a4e45 Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Tue, 12 Jul 2011 17:57:21 -0700 Subject: [PATCH] increase IPv4 parsing strictness yet more --- dns/ipv4.py | 6 ++++++ 1 file changed, 6 insertions(+) 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) -- 2.47.3