Fix Call for graph test and use a fixed itr for symbolic size

pull/1133/head
Nikhil 5 years ago
parent 60ee9f3c97
commit 2f6302a8c1
  1. 2
      mythril/analysis/symbolic.py
  2. 19
      mythril/laser/ethereum/state/memory.py

@ -215,7 +215,7 @@ class SymExecWrapper:
gas,
value,
state.mstate.memory[
meminstart.val : meminsz.val * 4
meminstart.val : meminsz.val + meminstart.val
],
)
)

@ -21,6 +21,10 @@ def convert_bv(val: Union[int, BitVec]) -> BitVec:
return symbol_factory.BitVecVal(val, 256)
# No of iterations to perform when iteration size is symbolic
APPROX_ITR = 100
class Memory:
"""A class representing contract memory with random access."""
@ -140,8 +144,14 @@ class Memory:
convert_bv(step),
)
ret_lis = []
symbolic_len = False
itr = symbol_factory.BitVecVal(0, 256)
while simplify(bvstart + itr < bvstop) and itr <= 10000000:
if (bvstop - bvstart).symbolic:
symbolic_len = True
while simplify(bvstart + bvstep * itr != bvstop) and (
not symbolic_len or itr <= APPROX_ITR
):
ret_lis.append(self[bvstart + bvstep * itr])
itr += 1
@ -177,8 +187,13 @@ class Memory:
convert_bv(stop),
convert_bv(step),
)
symbolic_len = False
itr = symbol_factory.BitVecVal(0, 256)
while simplify(bvstart + bvstep * itr < bvstop) and itr <= 10000000:
if (bvstop - bvstart).symbolic:
symbolic_len = True
while simplify(bvstart + bvstep * itr != bvstop) and (
not symbolic_len or itr <= APPROX_ITR
):
self[bvstart + itr * bvstep] = cast(List[Union[int, BitVec]], value)[
itr.value
]

Loading…
Cancel
Save