aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-06-13 02:19:49 +0800
committerGitHub <noreply@github.com>2018-06-13 02:19:49 +0800
commit3e1fb6b7ffed25f3f12bcf0fe474f2afc9396fe4 (patch)
tree24a9326bb17dd69cfe2420a225b9ab90bf67332a /libsolidity
parent451f56ec1cd032802b52ce81ad5950a441cf5e87 (diff)
parent1dc28c065d91416caf778770ef57b73b30462b8d (diff)
downloaddexon-solidity-3e1fb6b7ffed25f3f12bcf0fe474f2afc9396fe4.tar
dexon-solidity-3e1fb6b7ffed25f3f12bcf0fe474f2afc9396fe4.tar.gz
dexon-solidity-3e1fb6b7ffed25f3f12bcf0fe474f2afc9396fe4.tar.bz2
dexon-solidity-3e1fb6b7ffed25f3f12bcf0fe474f2afc9396fe4.tar.lz
dexon-solidity-3e1fb6b7ffed25f3f12bcf0fe474f2afc9396fe4.tar.xz
dexon-solidity-3e1fb6b7ffed25f3f12bcf0fe474f2afc9396fe4.tar.zst
dexon-solidity-3e1fb6b7ffed25f3f12bcf0fe474f2afc9396fe4.zip
Merge pull request #4085 from ethereum/calldatapad
[BREAKING] Properly pad data from calldata.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/codegen/ArrayUtils.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp
index 14c887c3..2b77db8f 100644
--- a/libsolidity/codegen/ArrayUtils.cpp
+++ b/libsolidity/codegen/ArrayUtils.cpp
@@ -303,12 +303,17 @@ void ArrayUtils::copyArrayToMemory(ArrayType const& _sourceType, bool _padToWord
m_context << _sourceType.length();
if (baseSize > 1)
m_context << u256(baseSize) << Instruction::MUL;
- // stack: target source_offset source_len
- m_context << Instruction::DUP1 << Instruction::DUP3 << Instruction::DUP5;
- // stack: target source_offset source_len source_len source_offset target
- m_context << Instruction::CALLDATACOPY;
- m_context << Instruction::DUP3 << Instruction::ADD;
- m_context << Instruction::SWAP2 << Instruction::POP << Instruction::POP;
+
+ string routine = "calldatacopy(target, source, len)\n";
+ if (_padToWordBoundaries)
+ routine += R"(
+ // Set padding suffix to zero
+ mstore(add(target, len), 0)
+ len := and(add(len, 0x1f), not(0x1f))
+ )";
+ routine += "target := add(target, len)\n";
+ m_context.appendInlineAssembly("{" + routine + "}", {"target", "source", "len"});
+ m_context << Instruction::POP << Instruction::POP;
}
else if (_sourceType.location() == DataLocation::Memory)
{