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)
829829 addr = static_cast <CNetAddr>(MaybeFlipIPv6toCJDNS (CService{addr.value (), /* port=*/ 0 }));
830830 if (slash_pos != subnet_str.npos ) {
831831 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)}) {
834833 // Valid number; assume CIDR variable-length subnet masking.
835- subnet = CSubNet{addr.value (), netmask};
834+ subnet = CSubNet{addr.value (), * netmask};
836835 } else {
837836 // Invalid number; try full netmask syntax. Never allow lookup for netmask.
838837 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)
150150
151151BOOST_AUTO_TEST_CASE (subnet_test)
152152{
153-
154153 BOOST_CHECK (LookupSubNet (" 1.2.3.0/24" ) == LookupSubNet (" 1.2.3.0/255.255.255.0" ));
155154 BOOST_CHECK (LookupSubNet (" 1.2.3.0/24" ) != LookupSubNet (" 1.2.4.0/255.255.255.0" ));
156155 BOOST_CHECK (LookupSubNet (" 1.2.3.0/24" ).Match (ResolveIP (" 1.2.3.4" )));
@@ -185,6 +184,7 @@ BOOST_AUTO_TEST_CASE(subnet_test)
185184 // Check valid/invalid
186185 BOOST_CHECK (LookupSubNet (" 1.2.3.0/0" ).IsValid ());
187186 BOOST_CHECK (!LookupSubNet (" 1.2.3.0/-1" ).IsValid ());
187+ BOOST_CHECK (!LookupSubNet (" 1.2.3.0/+24" ).IsValid ());
188188 BOOST_CHECK (LookupSubNet (" 1.2.3.0/32" ).IsValid ());
189189 BOOST_CHECK (!LookupSubNet (" 1.2.3.0/33" ).IsValid ());
190190 BOOST_CHECK (!LookupSubNet (" 1.2.3.0/300" ).IsValid ());
You can’t perform that action at this time.
0 commit comments