diff options
| author | Bob Halley <halley@nominum.com> | 2011-07-08 09:57:41 -0700 |
|---|---|---|
| committer | Bob Halley <halley@nominum.com> | 2011-07-08 09:57:41 -0700 |
| commit | 3d7524ab7da01cab4d7dd3857e56fd11e82c061e (patch) | |
| tree | 687b3734bacb55ac82d061106793122b3b8df3dc /dns/ipv6.py | |
| parent | 08e03cc0ee4911fbad029bd4703db89fa6324353 (diff) | |
| download | dnspython-3d7524ab7da01cab4d7dd3857e56fd11e82c061e.tar.gz | |
make IP address parsing stricter
Diffstat (limited to 'dns/ipv6.py')
| -rw-r--r-- | dns/ipv6.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/dns/ipv6.py b/dns/ipv6.py index 8363fe4..78fe82e 100644 --- a/dns/ipv6.py +++ b/dns/ipv6.py @@ -113,9 +113,16 @@ def inet_aton(text): # m = _v4_ending.match(text) if not m is None: - text = "%s:%04x:%04x" % (m.group(1), - int(m.group(2)) * 256 + int(m.group(3)), - int(m.group(4)) * 256 + int(m.group(5))) + try: + b1 = int(m.group(2)) + b2 = int(m.group(3)) + b3 = int(m.group(4)) + b4 = int(m.group(5)) + except: + raise dns.exception.SyntaxError + if b1 > 255 or b2 > 255 or b3 > 255 or b4 > 255: + raise dns.exception.SyntaxError + text = "%s:%04x:%04x" % (m.group(1), b1 * 256 + b2, b3 * 256 + b4) # # Try to turn '::<whatever>' into ':<whatever>'; if no match try to # turn '<whatever>::' into '<whatever>:' |
