Skip to content

Commit

Permalink
Merge branch 'seg_bad_mask' of https://github.com/sbentov/pysubnettree
Browse files Browse the repository at this point in the history
* 'seg_bad_mask' of https://github.com/sbentov/pysubnettree:
  only allow max mask of 32 for AF_INET

And added a similar check for masks greater than 128 for IPv6
  • Loading branch information
jsiwek committed Mar 22, 2019
2 parents 7655b36 + c649f59 commit aa68223
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@

0.28-11 | 2019-03-22 16:15:24 -0700

* Improve parsing/handling of invalid subnet strings (Shai Bentov)

* GH-12: fix segfault on invalid prefixes (Jon Siwek, Corelight)

* Fix python3 compatibility of ./configure script (Jon Siwek, Corelight)

0.28-2 | 2018-12-07 16:30:21 -0600

* Update github/download link (Jon Siwek, Corelight)
Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. -*- mode: rst-mode -*-
..
.. Version number is filled in automatically.
.. |version| replace:: 0.28-2
.. |version| replace:: 0.28-11

===============================================
PySubnetTree - A Python Module for CIDR Lookups
Expand Down
5 changes: 5 additions & 0 deletions SubnetTree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ inline static bool parse_cidr(const char *cidr, int *family, inx_addr *subnet, u

if ( endptr == mask_str || errno != 0 )
return false;

if ( *family == AF_INET && *mask > 32 )
return false;
else if ( *mask > 128 )
return false;
}
else {
if ( *family == AF_INET )
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.28-2
0.28-11
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
long_description = file.read()

setup(name="pysubnettree",
version="0.28-2", # Filled in automatically.
version="0.28-11", # Filled in automatically.
maintainer="The Bro Project",
maintainer_email="info@bro.org",
license="BSD",
Expand Down
5 changes: 5 additions & 0 deletions testing/pysubnettree/prefixes.test
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ expected = set(['2620:4d:4004:3::2/64', '10.1.0.0/16', '10.1.42.0/24', '1:2:3:4:
p = t.prefixes(ipv4_native=True) - expected
testcase(not p, "prefixes should include IPv4 native with len")

try:
# Expect an exception when giving an invalid prefix
t.insert('8.8.8.8/56')
except ValueError:
pass

0 comments on commit aa68223

Please sign in to comment.