more calldata fixes including natives

pull/557/head
Nathan 6 years ago
parent 738ffe035c
commit c428df83ee
  1. 2
      mythril/analysis/modules/ether_send.py
  2. 15
      mythril/laser/ethereum/instructions.py
  3. 2
      mythril/laser/ethereum/state.py

@ -112,7 +112,7 @@ def execute(statespace):
model = solver.get_model(node.constraints)
pretty_model = solver.pretty_print_model(model)
logging.debug(pretty_model)
logging.debug('[ETHER_SEND]\n' + pretty_model)
debug = "SOLVER OUTPUT:\n" + pretty_model

@ -13,7 +13,7 @@ from mythril.laser.ethereum.call import get_call_parameters
from mythril.laser.ethereum.evm_exceptions import VmException, StackUnderflowException, InvalidJumpDestination, \
InvalidInstruction
from mythril.laser.ethereum.keccak import KeccakFunctionManager
from mythril.laser.ethereum.state import GlobalState, CalldataType
from mythril.laser.ethereum.state import GlobalState, CalldataType, Calldata
from mythril.laser.ethereum.transaction import MessageCallTransaction, TransactionStartSignal, \
ContractCreationTransaction
@ -1030,8 +1030,17 @@ class Instruction:
return [global_state]
for i in range(min(len(data), mem_out_sz)): # If more data is used then it's chopped off
global_state.mstate.memory[mem_out_start + i] = data[i]
if type(data) == Calldata: # identity() returns calldata
new_memory = []
for i in range(mem_out_sz):
new_memory.append(data[i])
for i in range(0, len(new_memory), 32):
global_state.mstate.memory[mem_out_start + i] = simplify(Concat(new_memory[i:i+32]))
else:
for i in range(min(len(data), mem_out_sz)): # If more data is used then it's chopped off
global_state.mstate.memory[mem_out_start + i] = data[i]
# TODO: maybe use BitVec here constrained to 1
return [global_state]

@ -27,7 +27,7 @@ class Calldata:
concrete_calldata.sort(key=lambda x: x[0].as_long() if type(x) == list else -1)
result = []
arr_index = 1
for i in range(0, concrete_calldata[len(concrete_calldata)-1][0].as_long()+1):
for i in range(concrete_calldata[len(concrete_calldata)-1][0].as_long()+1):
if concrete_calldata[arr_index][0].as_long() == i:
result.append(concrete_calldata[arr_index][1].as_long())
arr_index += 1

Loading…
Cancel
Save