Fix ReturnData (#1683)

pull/1687/head
Nikhil Parasaram 2 years ago committed by GitHub
parent 822b1554fa
commit 1267c75854
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      mythril/laser/ethereum/instructions.py
  2. 6
      mythril/laser/ethereum/transaction/transaction_models.py
  3. 24
      solidity_examples/killbilly.sol

@ -1838,7 +1838,7 @@ class Instruction:
global_state.mstate.pop(3)
if global_state.last_return_data:
return_val = symbol_factory.BitVecVal(
int(global_state.last_return_data, 16), 256
int(global_state.last_return_data.return_data, 16), 256
)
else:
return_val = symbol_factory.BitVecVal(0, 256)

@ -8,6 +8,7 @@ from mythril.support.support_utils import Singleton
from mythril.laser.ethereum.state.calldata import ConcreteCalldata
from mythril.laser.ethereum.state.account import Account
from mythril.laser.ethereum.state.calldata import BaseCalldata, SymbolicCalldata
from mythril.laser.ethereum.state.return_data import ReturnData
from mythril.laser.ethereum.state.environment import Environment
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.ethereum.state.world_state import WorldState
@ -273,9 +274,8 @@ class ContractCreationTransaction(BaseTransaction):
global_state.environment.active_account.code.assign_bytecode(
tuple(return_data.return_data)
)
self.return_data = str(
hex(global_state.environment.active_account.address.value)
)
return_data = str(hex(global_state.environment.active_account.address.value))
self.return_data = ReturnData(return_data, len(return_data) // 2)
assert global_state.environment.active_account.code.instruction_list != []
raise TransactionEndSignal(global_state, revert=revert)

@ -0,0 +1,24 @@
pragma solidity 0.5.7;
contract KillBilly {
bool public is_killable;
mapping (address => bool) public approved_killers;
constructor() public {
is_killable = false;
}
function killerize(address addr) public {
approved_killers[addr] = true;
}
function activatekillability() public {
require(approved_killers[msg.sender] == true);
is_killable = true;
}
function commencekilling() public {
require(is_killable);
selfdestruct(msg.sender);
}
}
Loading…
Cancel
Save