fkie-cad / dewolf

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

[Pipeline] Crash due to Binja API changes #124

Closed mari-mari closed 2 years ago

mari-mari commented 2 years ago

What happened?

Due to changes in the latest Binja version, we have crash when decompiling custom non-library functions in Windows binaries. We test, if function name is in symbols. The test always returns True, but the list of symbols returned is empty. Thus we get the following error:

Traceback (most recent call last):
  File "decompile.py", line 80, in <module>
    main(Decompiler)
  File "/home/mry/.binaryninja/plugins/dewolf/decompiler/util/commandline.py", line 65, in main
    task = decompiler.decompile(function_name, options)
  File "decompile.py", line 54, in decompile
    task = self._frontend.create_task(function, task_options)
  File "/home/mry/.binaryninja/plugins/dewolf/decompiler/frontend/binaryninja/frontend.py", line 55, in create_task
    function = self._find_function(function)
  File "/home/mry/.binaryninja/plugins/dewolf/decompiler/frontend/binaryninja/frontend.py", line 75, in _find_function
    address = self._get_address(function)
  File "/home/mry/.binaryninja/plugins/dewolf/decompiler/frontend/binaryninja/frontend.py", line 100, in _get_address
    return sym[0].address
IndexError: list index out of range

Instead of checking if name in symbols:

    if text in self._bv.symbols:
            sym = self._bv.symbols[text]

we should check now if the list of symbols is empty:

if sym := self._bv.symbols.get(text, None):

How to reproduce?

python decompile.py tests/samples/others/test.exe 0x401865

Affected Binary Ninja Version(s)

3.1.3469

mari-mari commented 2 years ago

/cib

github-actions[bot] commented 2 years ago

Branch issue-124-_Pipeline_Crash_due_to_Binja_API_changes created!