Rewrite parsing of source mapping info

pull/72/head
Bernhard Mueller 7 years ago
parent 5b786e1866
commit 3d320e393c
  1. 16
      mythril/ether/soliditycontract.py
  2. 17
      mythril/support/truffle.py

@ -49,16 +49,16 @@ class SolidityContract(ETHContract):
for item in srcmap:
m = re.search(r"^(\d+):(\d+)", item)
mapping = item.split(":")
if (m):
offset = int(m.group(1))
length = int(m.group(2))
if len(mapping) > 0 and len(mapping[0]) > 0:
offset = int(mapping[0])
m = re.search(r"^\d+:\d+:(\d+)", item)
if (m):
idx = int(m.group(1))
if len(mapping) > 1 and len(mapping[1]) > 0:
length = int(mapping[1])
if len(mapping) > 2 and len(mapping[2]) > 0:
idx = int(mapping[2])
self.mappings.append(SourceMapping(idx, offset, length))

@ -57,23 +57,18 @@ def analyze_truffle_project():
mappings = []
i = 0
while(i < len(deployedSourceMap)):
for item in deployedSourceMap:
m = re.search(r"^(\d+):*(\d+)", deployedSourceMap[i])
mapping = item.split(":")
if (m):
offset = m.group(1)
length = m.group(2)
else:
m = re.search(r"^:(\d+)", deployedSourceMap[i])
if len(mapping) > 0 and len(mapping[0]) > 0:
offset = int(mapping[0])
if m:
length = m.group(1)
if len(mapping) > 1 and len(mapping[1]) > 0:
length = int(mapping[1])
mappings.append((int(offset), int(length)))
i += 1
for issue in issues:
index = helper.get_instruction_index(disassembly.instruction_list, issue.pc)

Loading…
Cancel
Save