File tree Expand file tree Collapse file tree 2 files changed +3
-4
lines changed Expand file tree Collapse file tree 2 files changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -829,10 +829,9 @@ CSubNet LookupSubNet(const std::string& subnet_str)
829
829
addr = static_cast <CNetAddr>(MaybeFlipIPv6toCJDNS (CService{addr.value (), /* port=*/ 0 }));
830
830
if (slash_pos != subnet_str.npos ) {
831
831
const std::string netmask_str{subnet_str.substr (slash_pos + 1 )};
832
- uint8_t netmask;
833
- if (ParseUInt8 (netmask_str, &netmask)) {
832
+ if (const auto netmask{ToIntegral<uint8_t >(netmask_str)}) {
834
833
// Valid number; assume CIDR variable-length subnet masking.
835
- subnet = CSubNet{addr.value (), netmask};
834
+ subnet = CSubNet{addr.value (), * netmask};
836
835
} else {
837
836
// Invalid number; try full netmask syntax. Never allow lookup for netmask.
838
837
const std::optional<CNetAddr> full_netmask{LookupHost (netmask_str, /* fAllowLookup=*/ false )};
Original file line number Diff line number Diff line change @@ -150,7 +150,6 @@ BOOST_AUTO_TEST_CASE(embedded_test)
150
150
151
151
BOOST_AUTO_TEST_CASE (subnet_test)
152
152
{
153
-
154
153
BOOST_CHECK (LookupSubNet (" 1.2.3.0/24" ) == LookupSubNet (" 1.2.3.0/255.255.255.0" ));
155
154
BOOST_CHECK (LookupSubNet (" 1.2.3.0/24" ) != LookupSubNet (" 1.2.4.0/255.255.255.0" ));
156
155
BOOST_CHECK (LookupSubNet (" 1.2.3.0/24" ).Match (ResolveIP (" 1.2.3.4" )));
@@ -185,6 +184,7 @@ BOOST_AUTO_TEST_CASE(subnet_test)
185
184
// Check valid/invalid
186
185
BOOST_CHECK (LookupSubNet (" 1.2.3.0/0" ).IsValid ());
187
186
BOOST_CHECK (!LookupSubNet (" 1.2.3.0/-1" ).IsValid ());
187
+ BOOST_CHECK (!LookupSubNet (" 1.2.3.0/+24" ).IsValid ());
188
188
BOOST_CHECK (LookupSubNet (" 1.2.3.0/32" ).IsValid ());
189
189
BOOST_CHECK (!LookupSubNet (" 1.2.3.0/33" ).IsValid ());
190
190
BOOST_CHECK (!LookupSubNet (" 1.2.3.0/300" ).IsValid ());
You can’t perform that action at this time.
0 commit comments