Merge #14398: tests: Don't access out of bounds array index: array[sizeof(array)]
b09c81454e
Don't access out of bounds array entry array[sizeof(array)] (Ben Woosley)
Pull request description:
Split from #13525
Tree-SHA512: bf44609fc5d497cd1894b85dce33a55977b3e0f3d03b986333a85967c1f3aa89089461f830939072bbb4d2477ccce26b9caeb627215bfb86a331f58d3466a4bd
This commit is contained in:
commit
2a747337ae
2 changed files with 6 additions and 6 deletions
|
@ -20,7 +20,7 @@ namespace block_bench {
|
|||
static void DeserializeBlockTest(benchmark::State& state)
|
||||
{
|
||||
CDataStream stream((const char*)block_bench::block413567,
|
||||
(const char*)&block_bench::block413567[sizeof(block_bench::block413567)],
|
||||
(const char*)block_bench::block413567 + sizeof(block_bench::block413567),
|
||||
SER_NETWORK, PROTOCOL_VERSION);
|
||||
char a = '\0';
|
||||
stream.write(&a, 1); // Prevent compaction
|
||||
|
@ -36,7 +36,7 @@ static void DeserializeBlockTest(benchmark::State& state)
|
|||
static void DeserializeAndCheckBlockTest(benchmark::State& state)
|
||||
{
|
||||
CDataStream stream((const char*)block_bench::block413567,
|
||||
(const char*)&block_bench::block413567[sizeof(block_bench::block413567)],
|
||||
(const char*)block_bench::block413567 + sizeof(block_bench::block413567),
|
||||
SER_NETWORK, PROTOCOL_VERSION);
|
||||
char a = '\0';
|
||||
stream.write(&a, 1); // Prevent compaction
|
||||
|
|
|
@ -1013,21 +1013,21 @@ BOOST_AUTO_TEST_CASE(script_PushData)
|
|||
|
||||
ScriptError err;
|
||||
std::vector<std::vector<unsigned char> > directStack;
|
||||
BOOST_CHECK(EvalScript(directStack, CScript(&direct[0], &direct[sizeof(direct)]), SCRIPT_VERIFY_P2SH, BaseSignatureChecker(), SigVersion::BASE, &err));
|
||||
BOOST_CHECK(EvalScript(directStack, CScript(direct, direct + sizeof(direct)), SCRIPT_VERIFY_P2SH, BaseSignatureChecker(), SigVersion::BASE, &err));
|
||||
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
|
||||
|
||||
std::vector<std::vector<unsigned char> > pushdata1Stack;
|
||||
BOOST_CHECK(EvalScript(pushdata1Stack, CScript(&pushdata1[0], &pushdata1[sizeof(pushdata1)]), SCRIPT_VERIFY_P2SH, BaseSignatureChecker(), SigVersion::BASE, &err));
|
||||
BOOST_CHECK(EvalScript(pushdata1Stack, CScript(pushdata1, pushdata1 + sizeof(pushdata1)), SCRIPT_VERIFY_P2SH, BaseSignatureChecker(), SigVersion::BASE, &err));
|
||||
BOOST_CHECK(pushdata1Stack == directStack);
|
||||
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
|
||||
|
||||
std::vector<std::vector<unsigned char> > pushdata2Stack;
|
||||
BOOST_CHECK(EvalScript(pushdata2Stack, CScript(&pushdata2[0], &pushdata2[sizeof(pushdata2)]), SCRIPT_VERIFY_P2SH, BaseSignatureChecker(), SigVersion::BASE, &err));
|
||||
BOOST_CHECK(EvalScript(pushdata2Stack, CScript(pushdata2, pushdata2 + sizeof(pushdata2)), SCRIPT_VERIFY_P2SH, BaseSignatureChecker(), SigVersion::BASE, &err));
|
||||
BOOST_CHECK(pushdata2Stack == directStack);
|
||||
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
|
||||
|
||||
std::vector<std::vector<unsigned char> > pushdata4Stack;
|
||||
BOOST_CHECK(EvalScript(pushdata4Stack, CScript(&pushdata4[0], &pushdata4[sizeof(pushdata4)]), SCRIPT_VERIFY_P2SH, BaseSignatureChecker(), SigVersion::BASE, &err));
|
||||
BOOST_CHECK(EvalScript(pushdata4Stack, CScript(pushdata4, pushdata4 + sizeof(pushdata4)), SCRIPT_VERIFY_P2SH, BaseSignatureChecker(), SigVersion::BASE, &err));
|
||||
BOOST_CHECK(pushdata4Stack == directStack);
|
||||
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue