mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Do not accept truncated function selectors.
This commit is contained in:
@@ -2899,6 +2899,25 @@ BOOST_AUTO_TEST_CASE(default_fallback_throws)
|
||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(0));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(short_data_calls_fallback)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
contract A {
|
||||
uint public x;
|
||||
// Signature is d88e0b00
|
||||
function fow() { x = 3; }
|
||||
function () { x = 2; }
|
||||
}
|
||||
)";
|
||||
compileAndRun(sourceCode);
|
||||
// should call fallback
|
||||
sendMessage(asBytes("\xd8\x8e\x0b"), false, 0);
|
||||
ABI_CHECK(callContractFunction("x()"), encodeArgs(2));
|
||||
// should call function
|
||||
sendMessage(asBytes(string("\xd8\x8e\x0b") + string(1, 0)), false, 0);
|
||||
ABI_CHECK(callContractFunction("x()"), encodeArgs(3));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(event)
|
||||
{
|
||||
char const* sourceCode = R"(
|
||||
|
||||
Reference in New Issue
Block a user