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)
20
20
std::string strDec = DecodeBase32 (vstrOut[i]);
21
21
BOOST_CHECK_EQUAL (strDec, vstrIn[i]);
22
22
}
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 );
23
34
}
24
35
25
36
BOOST_AUTO_TEST_SUITE_END ()
Original file line number Diff line number Diff line change @@ -20,6 +20,17 @@ BOOST_AUTO_TEST_CASE(base64_testvectors)
20
20
std::string strDec = DecodeBase64 (strEnc);
21
21
BOOST_CHECK_EQUAL (strDec, vstrIn[i]);
22
22
}
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 );
23
34
}
24
35
25
36
BOOST_AUTO_TEST_SUITE_END ()
Original file line number Diff line number Diff line change @@ -1069,6 +1069,11 @@ BOOST_AUTO_TEST_CASE(util_ParseMoney)
1069
1069
1070
1070
// Parsing negative amounts must fail
1071
1071
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));
1072
1077
}
1073
1078
1074
1079
BOOST_AUTO_TEST_CASE (util_IsHex)
You can’t perform that action at this time.
0 commit comments