aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/codegen/ContractCompiler.cpp
diff options
context:
space:
mode:
authorYoichi Hirai <i@yoichihirai.com>2017-10-18 17:22:21 +0800
committerGitHub <noreply@github.com>2017-10-18 17:22:21 +0800
commit4a9a986d8cf2e457ab1b36e20bcbefb714292a37 (patch)
tree82b6eb1132ecbf8c243ac2d796e891c7de8c53e3 /libsolidity/codegen/ContractCompiler.cpp
parenta17996cdadc9e6e941ee7c85681ad3e30f9cf998 (diff)
parent7849b920cf3ba6502f8a45e0c35be6393392cc00 (diff)
downloaddexon-solidity-4a9a986d8cf2e457ab1b36e20bcbefb714292a37.tar
dexon-solidity-4a9a986d8cf2e457ab1b36e20bcbefb714292a37.tar.gz
dexon-solidity-4a9a986d8cf2e457ab1b36e20bcbefb714292a37.tar.bz2
dexon-solidity-4a9a986d8cf2e457ab1b36e20bcbefb714292a37.tar.lz
dexon-solidity-4a9a986d8cf2e457ab1b36e20bcbefb714292a37.tar.xz
dexon-solidity-4a9a986d8cf2e457ab1b36e20bcbefb714292a37.tar.zst
dexon-solidity-4a9a986d8cf2e457ab1b36e20bcbefb714292a37.zip
Merge pull request #3065 from ethereum/reject_truncated_selectors
Do not accept truncated function selectors.
Diffstat (limited to 'libsolidity/codegen/ContractCompiler.cpp')
-rw-r--r--libsolidity/codegen/ContractCompiler.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp
index 429db532..74565ae4 100644
--- a/libsolidity/codegen/ContractCompiler.cpp
+++ b/libsolidity/codegen/ContractCompiler.cpp
@@ -251,13 +251,10 @@ void ContractCompiler::appendFunctionSelector(ContractDefinition const& _contrac
FunctionDefinition const* fallback = _contract.fallbackFunction();
eth::AssemblyItem notFound = m_context.newTag();
- // shortcut messages without data if we have many functions in order to be able to receive
- // ether with constant gas
- if (interfaceFunctions.size() > 5 || fallback)
- {
- m_context << Instruction::CALLDATASIZE << Instruction::ISZERO;
- m_context.appendConditionalJumpTo(notFound);
- }
+ // directly jump to fallback if the data is too short to contain a function selector
+ // also guards against short data
+ m_context << u256(4) << Instruction::CALLDATASIZE << Instruction::LT;
+ m_context.appendConditionalJumpTo(notFound);
// retrieve the function signature hash from the calldata
if (!interfaceFunctions.empty())