fkie-cad / dewolf

A research decompiler implemented as a Binary Ninja plugin.
GNU Lesser General Public License v2.1
171 stars 9 forks source link

CFG creation: list index out of range #186

Closed NeoQuix closed 1 year ago

NeoQuix commented 1 year ago

What happened?

[frontend.py:135 create_task()] ERROR - Failed to decompile main, error during CFG creation: list index out of range
Traceback (most recent call last):
  File "/home/neoquix/Git-Repos/DeWolf/decompile.py", line 80, in <module>
    main(Decompiler)
  File "/home/neoquix/Git-Repos/DeWolf/decompiler/util/commandline.py", line 87, in main
    task = decompiler.decompile(function_name, options)
  File "/home/neoquix/Git-Repos/DeWolf/decompile.py", line 54, in decompile
    task = self._frontend.create_task(function, task_options)
  File "/home/neoquix/Git-Repos/DeWolf/decompiler/frontend/binaryninja/frontend.py", line 137, in create_task
    raise e
  File "/home/neoquix/Git-Repos/DeWolf/decompiler/frontend/binaryninja/frontend.py", line 126, in create_task
    cfg = self._extract_cfg(function.function, options)
  File "/home/neoquix/Git-Repos/DeWolf/decompiler/frontend/binaryninja/frontend.py", line 156, in _extract_cfg
    return parser.parse(function)
  File "/home/neoquix/Git-Repos/DeWolf/decompiler/frontend/binaryninja/parser.py", line 34, in parse
    index_to_BasicBlock[basic_block.index] = BasicBlock(basic_block.index, instructions=list(self._lift_instructions(basic_block)))
  File "/home/neoquix/Git-Repos/DeWolf/decompiler/frontend/binaryninja/parser.py", line 77, in _lift_instructions
    if lifted_instruction := self._lifter.lift(instruction):
  File "/home/neoquix/Git-Repos/DeWolf/decompiler/frontend/binaryninja/lifter.py", line 28, in lift
    if pseudo_expression := handler(expression, **kwargs):
  File "/home/neoquix/Git-Repos/DeWolf/decompiler/frontend/binaryninja/handlers/assignments.py", line 51, in lift_assignment
    self._lifter.lift(assignment.src, parent=assignment),
  File "/home/neoquix/Git-Repos/DeWolf/decompiler/frontend/binaryninja/lifter.py", line 28, in lift
    if pseudo_expression := handler(expression, **kwargs):
  File "/home/neoquix/Git-Repos/DeWolf/decompiler/frontend/binaryninja/handlers/constants.py", line 57, in lift_constant_pointer
    return self._lift_const_addr(view, pointer)
  File "/home/neoquix/Git-Repos/DeWolf/decompiler/frontend/binaryninja/handlers/constants.py", line 80, in _lift_const_addr
    if var_ref_string else self._get_raw_bytes(view, pointer.constant)
  File "/home/neoquix/Git-Repos/DeWolf/decompiler/frontend/binaryninja/handlers/constants.py", line 91, in _get_raw_bytes
    return view.read(addr, view.get_sections_at(addr)[0].end)
IndexError: list index out of range

How to reproduce?

Decompile the main of the following bin: nice.zip

Affected Binary Ninja Version(s)

Version 3.3.3996

NeoQuix commented 1 year ago

Problem with CONST_PTR which yields negative constants. (example: &-0x27)

NeoQuix commented 1 year ago

/cib

github-actions[bot] commented 1 year ago

Branch issue-186-CFG_creation_list_index_out_of_range created!