diff --git a/manticore/platforms/evm.py b/manticore/platforms/evm.py index 261e730..81cb576 100644 --- a/manticore/platforms/evm.py +++ b/manticore/platforms/evm.py @@ -1805,10 +1805,8 @@ class EVM(Eventful): return data def write_buffer(self, offset, buf): - count = 0 - for c in buf: - self._store(offset + count, c) - count += 1 + for i, c in enumerate(buf): + self._store(offset+i, Operators.ORD(c)) def CREATE(self, value, offset, size): '''Create a new account with associated code''' diff --git a/tests/test_eth.py b/tests/test_eth.py index bbdf612..23c3b3e 100644 --- a/tests/test_eth.py +++ b/tests/test_eth.py @@ -102,3 +102,23 @@ class EthTests(unittest.TestCase): x = mevm.create_account(balance=0) contract_account = mevm.solidity_create_contract(source_code, contract_name="C", owner=owner, args=[x]) + + def test_writebuffer_doesnt_raise(self): + mevm = ManticoreEVM() + source_code = """ + contract X { + mapping(address => uint) private balance; + function f(address z) returns (uint) { return balance[z]; } + } + contract C { + X y; + function C() { + y = new X(); + uint z = y.f(0); + } + }""" + # Make sure that write_buffer (used by RETURN) succeeds without errors + owner = mevm.create_account(balance=1000) + x = mevm.create_account(balance=0) + contract_account = mevm.solidity_create_contract(source_code, + contract_name="C", owner=owner, args=[x])