Rewrite parsing of source mapping info

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

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

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

Loading…
Cancel
Save