Fix onsite storage by using proper variables (#1194)

pull/1198/head
Nikhil Parasaram 5 years ago committed by GitHub
parent 2eb94f3043
commit 0281be777b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      mythril/laser/ethereum/state/account.py

@ -75,7 +75,9 @@ class Storage:
def __getitem__(self, item: BitVec) -> BitVec: def __getitem__(self, item: BitVec) -> BitVec:
storage, is_keccak_storage = self._get_corresponding_storage(item) storage, is_keccak_storage = self._get_corresponding_storage(item)
if is_keccak_storage: if is_keccak_storage:
item = self._sanitize(cast(BitVecFunc, item).input_) sanitized_item = self._sanitize(cast(BitVecFunc, item).input_)
else:
sanitized_item = item
if ( if (
self.address self.address
and self.address.value != 0 and self.address.value != 0
@ -84,7 +86,7 @@ class Storage:
and (self.dynld and self.dynld.storage_loading) and (self.dynld and self.dynld.storage_loading)
): ):
try: try:
storage[item] = symbol_factory.BitVecVal( storage[sanitized_item] = symbol_factory.BitVecVal(
int( int(
self.dynld.read_storage( self.dynld.read_storage(
contract_address="0x{:040X}".format(self.address.value), contract_address="0x{:040X}".format(self.address.value),
@ -95,11 +97,11 @@ class Storage:
256, 256,
) )
self.storage_keys_loaded.add(int(item.value)) self.storage_keys_loaded.add(int(item.value))
self.printable_storage[item] = storage[item] self.printable_storage[item] = storage[sanitized_item]
except ValueError as e: except ValueError as e:
log.debug("Couldn't read storage at %s: %s", item, e) log.debug("Couldn't read storage at %s: %s", item, e)
return simplify(storage[item]) return simplify(storage[sanitized_item])
@staticmethod @staticmethod
def get_map_index(key: BitVec) -> BitVec: def get_map_index(key: BitVec) -> BitVec:

Loading…
Cancel
Save