File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed
Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,17 @@ BOOST_AUTO_TEST_CASE(base32_testvectors)
2020 std::string strDec = DecodeBase32 (vstrOut[i]);
2121 BOOST_CHECK_EQUAL (strDec, vstrIn[i]);
2222 }
23+
24+ // Decoding strings with embedded NUL characters should fail
25+ bool failure;
26+ (void )DecodeBase32 (std::string (" invalid" , 7 ), &failure);
27+ BOOST_CHECK_EQUAL (failure, true );
28+ (void )DecodeBase32 (std::string (" AWSX3VPP" , 8 ), &failure);
29+ BOOST_CHECK_EQUAL (failure, false );
30+ (void )DecodeBase32 (std::string (" AWSX3VPP\0 invalid" , 16 ), &failure);
31+ BOOST_CHECK_EQUAL (failure, true );
32+ (void )DecodeBase32 (std::string (" AWSX3VPPinvalid" , 15 ), &failure);
33+ BOOST_CHECK_EQUAL (failure, true );
2334}
2435
2536BOOST_AUTO_TEST_SUITE_END ()
Original file line number Diff line number Diff line change @@ -20,6 +20,17 @@ BOOST_AUTO_TEST_CASE(base64_testvectors)
2020 std::string strDec = DecodeBase64 (strEnc);
2121 BOOST_CHECK_EQUAL (strDec, vstrIn[i]);
2222 }
23+
24+ // Decoding strings with embedded NUL characters should fail
25+ bool failure;
26+ (void )DecodeBase64 (std::string (" invalid" , 7 ), &failure);
27+ BOOST_CHECK_EQUAL (failure, true );
28+ (void )DecodeBase64 (std::string (" nQB/pZw=" , 8 ), &failure);
29+ BOOST_CHECK_EQUAL (failure, false );
30+ (void )DecodeBase64 (std::string (" nQB/pZw=\0 invalid" , 16 ), &failure);
31+ BOOST_CHECK_EQUAL (failure, true );
32+ (void )DecodeBase64 (std::string (" nQB/pZw=invalid" , 15 ), &failure);
33+ BOOST_CHECK_EQUAL (failure, true );
2334}
2435
2536BOOST_AUTO_TEST_SUITE_END ()
Original file line number Diff line number Diff line change @@ -1069,6 +1069,11 @@ BOOST_AUTO_TEST_CASE(util_ParseMoney)
10691069
10701070 // Parsing negative amounts must fail
10711071 BOOST_CHECK (!ParseMoney (" -1" , ret));
1072+
1073+ // Parsing strings with embedded NUL characters should fail
1074+ BOOST_CHECK (!ParseMoney (std::string (" \0 -1" , 3 ), ret));
1075+ BOOST_CHECK (!ParseMoney (std::string (" \01 " , 2 ), ret));
1076+ BOOST_CHECK (!ParseMoney (std::string (" 1\0 " , 2 ), ret));
10721077}
10731078
10741079BOOST_AUTO_TEST_CASE (util_IsHex)
You can’t perform that action at this time.
0 commit comments