Skip to content

Commit

Permalink
Add test to investigate uninitialized padded code issue
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Aug 2, 2021
1 parent 9570ee0 commit 07deca0
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/unittests/evm_other_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/// - evmone's internal tests.

#include "evm_fixture.hpp"
#include <evmone/baseline.hpp>
#include <evmone/limits.hpp>

using evmone::test::evm;
Expand Down Expand Up @@ -151,3 +152,35 @@ TEST_P(evm, jumpdest_with_high_offset)
EXPECT_EQ(result.status_code, EVMC_SUCCESS) << "JUMPDEST at " << offset;
}
}

TEST_P(evm, random445)
{
const auto codehex =
"7f00000000000000000000000000000000000000000000000000000000000000017f00000000000000000000"
"0000ffffffffffffffffffffffffffffffffffffffff7f00000000000000000000000000000000000000000000"
"0000000000000000c3507f000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57f00"
"0000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b57fffffffffffffffffffffffffff"
"fffffffffffffffffffffffffffffffffffffe7f000000000000000000000000ffffffffffffffffffffffffff"
"ffffffffffffff7f00000000000000000000000000000000000000000000000000000000000000008756993365"
"a1376155";

const auto code = bytecode{} +
push("0000000000000000000000000000000000000000000000000000000000000001") +
push("000000000000000000000000ffffffffffffffffffffffffffffffffffffffff") +
push("000000000000000000000000000000000000000000000000000000000000c350") +
push("000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5") +
push("000000000000000000000000945304eb96065b2a98b57a48a06ae28d285a71b5") +
push("fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe") +
push("000000000000000000000000ffffffffffffffffffffffffffffffffffffffff") +
push("0000000000000000000000000000000000000000000000000000000000000000") +
OP_DUP8 + OP_JUMP + OP_SWAP10 + OP_CALLER + OP_PUSH6 + "a1376155";

ASSERT_EQ(hex(code), codehex);

const auto a = evmone::baseline::analyze(code.data(), code.size());
EXPECT_EQ(a.jumpdest_map.size(), code.size());
EXPECT_EQ(std::count(a.jumpdest_map.begin(), a.jumpdest_map.end(), true), 0);

execute(code);
EXPECT_STATUS(EVMC_BAD_JUMP_DESTINATION);
}

0 comments on commit 07deca0

Please sign in to comment.