Trim 0x prefix on codecopy state transition (Issue #705) (#729)

* Trim 0x prefix on codecopy state transition

* Trimming 0x before sending to `load_from_bytecode()`

* Delete config.ini

* Remove unused trim0x function

* Reformat instructions.py with black

* Update mythril/interfaces/cli.py

More idiomatic, thanks

Co-Authored-By: cleanunicorn <lucadanielcostin@gmail.com>

* Changes based on review, more idiomatic

* Trim 0x with oneliner if for code loaded from file
pull/760/head
Luca Daniel 6 years ago committed by JoranHonig
parent c600ddc3e5
commit 1884d4c79f
  1. 4
      mythril/interfaces/cli.py
  2. 2
      mythril/laser/ethereum/instructions.py

@ -325,9 +325,11 @@ def main():
if args.code: if args.code:
# Load from bytecode # Load from bytecode
address, _ = mythril.load_from_bytecode(args.code, args.bin_runtime) code = args.code[2:] if args.code.startswith("0x") else args.code
address, _ = mythril.load_from_bytecode(code, args.bin_runtime)
elif args.codefile: elif args.codefile:
bytecode = "".join([l.strip() for l in args.codefile if len(l.strip()) > 0]) bytecode = "".join([l.strip() for l in args.codefile if len(l.strip()) > 0])
bytecode = bytecode[2:] if bytecode.startswith("0x") else bytecode
address, _ = mythril.load_from_bytecode(bytecode, args.bin_runtime) address, _ = mythril.load_from_bytecode(bytecode, args.bin_runtime)
elif args.address: elif args.address:
# Get bytecode from a contract address # Get bytecode from a contract address

@ -706,7 +706,7 @@ class Instruction:
if size == 0 and isinstance( if size == 0 and isinstance(
global_state.current_transaction, ContractCreationTransaction global_state.current_transaction, ContractCreationTransaction
): ):
if concrete_code_offset >= len(global_state.environment.code.bytecode) // 2: if concrete_code_offset >= len(bytecode) // 2:
global_state.mstate.mem_extend(concrete_memory_offset, 1) global_state.mstate.mem_extend(concrete_memory_offset, 1)
global_state.mstate.memory[ global_state.mstate.memory[
concrete_memory_offset concrete_memory_offset

Loading…
Cancel
Save