Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue36845

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:ipaddres.IPv4Network and ipaddress.IPv6Network tuple construction will accept out of valid range prefixlen
Type:behaviorStage:resolved
Components:Library (Lib)Versions:Python 3.8, Python 3.7
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: SilentGhost, methane, niconorsk, pmoody, serhiy.storchaka
Priority:normalKeywords:patch

Created on2019-05-07 22:53 byniconorsk, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.

Pull Requests
URLStatusLinkedEdit
PR 13298mergedniconorsk,2019-05-13 22:03
PR 13309mergedmiss-islington,2019-05-14 10:33
Messages (6)
msg341839 -(view)Author: Nicolai Moore (niconorsk)*Date: 2019-05-07 22:53
When using the tuple-form of constructing IPv4Network and IPv6Network will accept prefixlen outside of the normal allowed ranges.Example:>>> import ipaddress>>> ipaddress.IPv4Network(('172.21.1.0', 400))IPv4Network('172.21.1.0/400')If given a negative number, it will error but not with a particularly useful error:>>> x = ipaddress.IPv4Network(('172.21.1.0', -1))Traceback (most recent call last):  File "<stdin>", line 1, in <module>  File "/usr/lib64/python3.7/ipaddress.py", line 1532, in __init__    self.netmask, self._prefixlen = self._make_netmask(mask)  File "/usr/lib64/python3.7/ipaddress.py", line 1112, in _make_netmask    netmask = IPv4Address(cls._ip_int_from_prefix(prefixlen))  File "/usr/lib64/python3.7/ipaddress.py", line 444, in _ip_int_from_prefix    return cls._ALL_ONES ^ (cls._ALL_ONES >> prefixlen)ValueError: negative shift countLooking at the code, I think all that is needed is a range check within the respective _make_netmask methods in _BaseV4 and _BaseV6 classes
msg341861 -(view)Author: SilentGhost (SilentGhost)*(Python triager)Date: 2019-05-08 10:22
Would you like to submit a fix, Nicolai?
msg341862 -(view)Author: Nicolai Moore (niconorsk)*Date: 2019-05-08 10:35
I'd be happy too. Would be a first time contribution though, so need to give me some time to figure my way around the process.
msg341863 -(view)Author: SilentGhost (SilentGhost)*(Python triager)Date: 2019-05-08 10:45
There are some guidelines available athttps://devguide.python.org/pullrequest/
msg342448 -(view)Author: Inada Naoki (methane)*(Python committer)Date: 2019-05-14 10:33
New changeset5e48e3db6f5a937023e99d89cef8884d22bd8533 by Inada Naoki (Nicolai Moore) in branch 'master':bpo-36845: validate integer network prefix when constructing IP networks (GH-13298)https://github.com/python/cpython/commit/5e48e3db6f5a937023e99d89cef8884d22bd8533
msg342449 -(view)Author: Inada Naoki (methane)*(Python committer)Date: 2019-05-14 11:00
New changeset30cccf084d1560d9e3382e69d828b3be8cdb0286 by Inada Naoki (Miss Islington (bot)) in branch '3.7':bpo-36845: validate integer network prefix when constructing IP networks (GH-13298)https://github.com/python/cpython/commit/30cccf084d1560d9e3382e69d828b3be8cdb0286
History
DateUserActionArgs
2022-04-11 14:59:14adminsetgithub: 81026
2019-05-14 11:00:45methanesetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-05-14 11:00:21methanesetmessages: +msg342449
2019-05-14 10:33:15miss-islingtonsetpull_requests: +pull_request13219
2019-05-14 10:33:05methanesetnosy: +methane
messages: +msg342448
2019-05-13 22:03:01niconorsksetkeywords: +patch
stage: needs patch -> patch review
pull_requests: +pull_request13208
2019-05-08 10:45:35SilentGhostsetmessages: +msg341863
2019-05-08 10:35:30niconorsksetmessages: +msg341862
2019-05-08 10:23:30SilentGhostsetnosy: +serhiy.storchaka
2019-05-08 10:22:05SilentGhostsetversions: - Python 3.5, Python 3.6, Python 3.9
nosy: +pmoody,SilentGhost

messages: +msg341861

stage: needs patch
2019-05-07 22:53:58niconorskcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp