quarkslab / python-binexport

Python interface for Binexport, the Bindiff export format
Apache License 2.0
14 stars 2 forks source link

BinExport is trowing an exception #1

Closed Fenrisfulsur closed 10 months ago

Fenrisfulsur commented 1 year ago

BinExport is trowing an exception (in binexport/function.py) when using the following code:

    p = qbindiff.Program(qbindiff.LoaderType.binexport, './firmware3v3.bin.BinExport')
    q = qbindiff.Program(qbindiff.LoaderType.binexport, './bootloader-apploader.axf.BinExport')
    differ = qbindiff.QBinDiff(p, q)
    differ.register_feature_extractor(qbindiff.features.BBlockNb, 1.0)
    matches = differ.compute_matching()
    ...

we get this error:

  File "binexport/function.py", line 174, in graph
    _ = self.blocks  # Load the CFG
  File "functools.py", line 981, in __get__
    val = self.func(instance)
  File "binexport/function.py", line 141, in blocks
    for bb_idx in self._pb_fun.basic_block_index:
AttributeError: 'NoneType' object has no attribute 'basic_block_index'

Which can be patched with the following (in binexport/function.py):

137  # Add a sanity check to prevent error, for yet unknown reason _pb_fun may be undefined
138  if self._pb_fun == None:
139    return bblocks
patacca commented 10 months ago

Fixed in #8. Feel free to open the issue again if the problem is still present.