Do not accept truncated function selectors.

This commit is contained in:
chriseth
2017-10-17 23:17:36 +02:00
parent a17996cdad
commit a3db1fc197
3 changed files with 25 additions and 7 deletions
+19
View File
@@ -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"(