diff options
author | Nicolai Moore <niconorsk@gmail.com> | 2019-05-14 10:32:59 (GMT) |
---|---|---|
committer | Inada Naoki <songofacandy@gmail.com> | 2019-05-14 10:32:59 (GMT) |
commit | 5e48e3db6f5a937023e99d89cef8884d22bd8533 (patch) | |
tree | a3d3ca95253f60968046c87393d29a86b3ab7ca6 /Lib/ipaddress.py | |
parent | f0be4bbb9b3cee876249c23f2ae6f38f43fa7495 (diff) | |
download | cpython-5e48e3db6f5a937023e99d89cef8884d22bd8533.zip cpython-5e48e3db6f5a937023e99d89cef8884d22bd8533.tar.gz cpython-5e48e3db6f5a937023e99d89cef8884d22bd8533.tar.bz2 |
bpo-36845: validate integer network prefix when constructing IP networks (GH-13298)
Diffstat (limited to 'Lib/ipaddress.py')
-rw-r--r-- | Lib/ipaddress.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index 662d737..873c764 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -1108,6 +1108,8 @@ class _BaseV4: if arg not in cls._netmask_cache: if isinstance(arg, int): prefixlen = arg + if not (0 <= prefixlen <= cls._max_prefixlen): + cls._report_invalid_netmask(prefixlen) else: try: # Check for a netmask in prefix length form @@ -1538,6 +1540,8 @@ class _BaseV6: if arg not in cls._netmask_cache: if isinstance(arg, int): prefixlen = arg + if not (0 <= prefixlen <= cls._max_prefixlen): + cls._report_invalid_netmask(prefixlen) else: prefixlen = cls._prefix_from_prefix_string(arg) netmask = IPv6Address(cls._ip_int_from_prefix(prefixlen)) |