summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Halley <halley@nominum.com>2011-07-12 17:57:21 -0700
committerBob Halley <halley@nominum.com>2011-07-12 17:57:21 -0700
commit490083eebe545d753089f9ec90957d5ec68a4e45 (patch)
tree223e0cb94ba9436183e9229554150616a8b59979
parentc492addec82e325ef77e95d9a53775d3fe60d056 (diff)
downloaddnspython-490083eebe545d753089f9ec90957d5ec68a4e45.tar.gz
increase IPv4 parsing strictness yet more
-rw-r--r--dns/ipv4.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/dns/ipv4.py b/dns/ipv4.py
index 1860ddc..f3b6c5c 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)