summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Halley <halley@nominum.com>2011-07-12 17:56:56 -0700
committerBob Halley <halley@nominum.com>2011-07-12 17:56:56 -0700
commite189940dec42495869483f71b0be119bf8956d60 (patch)
tree1a3469aac345bafc0d507af29379324d61648cd9
parent3d7524ab7da01cab4d7dd3857e56fd11e82c061e (diff)
downloaddnspython-e189940dec42495869483f71b0be119bf8956d60.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 ec7d2d2..e117966 100644
--- a/dns/ipv4.py
+++ b/dns/ipv4.py
@@ -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)