summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Moody <pmoody@google.com>2012-06-29 11:26:20 -0700
committerPeter Moody <pmoody@google.com>2012-06-29 11:26:20 -0700
commit8d1eeed6e9f61939fee65b78748248f17ce919e4 (patch)
tree6227ab1f82b6d5c81df8ec08111d6dd4e9e79490
parent0ae2f93f8ff86068789752c276963f9a659812ff (diff)
downloadipaddr-py-8d1eeed6e9f61939fee65b78748248f17ce919e4.tar.gz
ipaddr incorrectly parses some V6 addresses.
issue97.
-rw-r--r--trunk/ipaddr.py2
-rwxr-xr-xtrunk/ipaddr_test.py1
2 files changed, 3 insertions, 0 deletions
diff --git a/trunk/ipaddr.py b/trunk/ipaddr.py
index b1d8f74..30768d9 100644
--- a/trunk/ipaddr.py
+++ b/trunk/ipaddr.py
@@ -1490,6 +1490,8 @@ class _BaseV6(object):
# Whitelist the characters, since int() allows a lot of bizarre stuff.
if not self._HEX_DIGITS.issuperset(hextet_str):
raise ValueError
+ if len(hextet_str) > 4:
+ raise ValueError
hextet_int = int(hextet_str, 16)
if hextet_int > 0xFFFF:
raise ValueError
diff --git a/trunk/ipaddr_test.py b/trunk/ipaddr_test.py
index 9446889..5f50961 100755
--- a/trunk/ipaddr_test.py
+++ b/trunk/ipaddr_test.py
@@ -133,6 +133,7 @@ class IpaddrUnitTest(unittest.TestCase):
AssertInvalidIP(":1:2:3:4:5:6:")
AssertInvalidIP("192.0.2.1/32")
AssertInvalidIP("2001:db8::1/128")
+ AssertInvalidIP("02001:db8::")
self.assertRaises(ipaddr.AddressValueError, ipaddr.IPv4Network, '')
self.assertRaises(ipaddr.AddressValueError, ipaddr.IPv4Network,