Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
norhh authored Dec 2, 2018
2 parents 81974e2 + 198dbd1 commit 1a4def9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 9 additions & 1 deletion mythril/laser/ethereum/instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def __init__(self, op_code: str, dynamic_loader: DynLoader):
def evaluate(self, global_state: GlobalState, post=False) -> List[GlobalState]:
""" Performs the mutation for this instruction """
# Generalize some ops
# logging.debug("Evaluating {}".format(self.op_code))
logging.debug("Evaluating {}".format(self.op_code))
op = self.op_code.lower()
if self.op_code.startswith("PUSH"):
op = "push"
Expand Down Expand Up @@ -773,6 +773,14 @@ def extcodecopy_(self, global_state: GlobalState) -> List[GlobalState]:

return [global_state]

@StateTransition()
def returndatacopy_(self, global_state: GlobalState) -> List[GlobalState]:
# FIXME: not implemented
state = global_state.mstate
start, s2, size = state.stack.pop(), state.stack.pop(), state.stack.pop()

return [global_state]

@StateTransition()
def returndatasize_(self, global_state: GlobalState) -> List[GlobalState]:
global_state.mstate.stack.append(global_state.new_bitvec("returndatasize", 256))
Expand Down
5 changes: 2 additions & 3 deletions mythril/laser/ethereum/state/calldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,17 @@ def __init__(self, tx_id: int):
:param tx_id: Id of the transaction that the calldata is for.
"""
self._reads = []
self._size = BitVec("calldatasize", 256)
self._size = BitVec(str(tx_id) + "_calldatasize", 256)
super().__init__(tx_id)

def _load(self, item: Union[int, ExprRef], clean=False) -> Any:
x = BitVecVal(item, 256) if isinstance(item, int) else item

symbolic_base_value = If(
x > self._size,
x >= self._size,
BitVecVal(0, 8),
BitVec("{}_calldata_{}".format(self.tx_id, str(item)), 8),
)

return_value = symbolic_base_value
for r_index, r_value in self._reads:
return_value = If(r_index == item, r_value, return_value)
Expand Down

0 comments on commit 1a4def9

Please sign in to comment.