@@ -127,7 +127,6 @@ BOOST_AUTO_TEST_CASE(netbase_lookupnumeric)
127
127
128
128
BOOST_AUTO_TEST_CASE (onioncat_test)
129
129
{
130
-
131
130
// values from https://web.archive.org/web/20121122003543/http://www.cypherpunk.at/onioncat/wiki/OnionCat
132
131
CNetAddr addr1 (ResolveIP (" 5wyqrzbvrdsumnok.onion" ));
133
132
CNetAddr addr2 (ResolveIP (" FD87:D87E:EB43:edb1:8e4:3588:e546:35ca" ));
@@ -402,4 +401,22 @@ BOOST_AUTO_TEST_CASE(netpermissions_test)
402
401
BOOST_CHECK (std::find (strings.begin (), strings.end (), " mempool" ) != strings.end ());
403
402
}
404
403
404
+ BOOST_AUTO_TEST_CASE (netbase_dont_resolve_strings_with_embedded_nul_characters)
405
+ {
406
+ CNetAddr addr;
407
+ BOOST_CHECK (LookupHost (std::string (" 127.0.0.1" , 9 ), addr, false ));
408
+ BOOST_CHECK (!LookupHost (std::string (" 127.0.0.1\0 " , 10 ), addr, false ));
409
+ BOOST_CHECK (!LookupHost (std::string (" 127.0.0.1\0 example.com" , 21 ), addr, false ));
410
+ BOOST_CHECK (!LookupHost (std::string (" 127.0.0.1\0 example.com\0 " , 22 ), addr, false ));
411
+ CSubNet ret;
412
+ BOOST_CHECK (LookupSubNet (std::string (" 1.2.3.0/24" , 10 ), ret));
413
+ BOOST_CHECK (!LookupSubNet (std::string (" 1.2.3.0/24\0 " , 11 ), ret));
414
+ BOOST_CHECK (!LookupSubNet (std::string (" 1.2.3.0/24\0 example.com" , 22 ), ret));
415
+ BOOST_CHECK (!LookupSubNet (std::string (" 1.2.3.0/24\0 example.com\0 " , 23 ), ret));
416
+ BOOST_CHECK (LookupSubNet (std::string (" 5wyqrzbvrdsumnok.onion" , 22 ), ret));
417
+ BOOST_CHECK (!LookupSubNet (std::string (" 5wyqrzbvrdsumnok.onion\0 " , 23 ), ret));
418
+ BOOST_CHECK (!LookupSubNet (std::string (" 5wyqrzbvrdsumnok.onion\0 example.com" , 34 ), ret));
419
+ BOOST_CHECK (!LookupSubNet (std::string (" 5wyqrzbvrdsumnok.onion\0 example.com\0 " , 35 ), ret));
420
+ }
421
+
405
422
BOOST_AUTO_TEST_SUITE_END ()
0 commit comments