Skip to content

UnicodeDecodeError when getting data var name #7604

@CalebFenton

Description

@CalebFenton

Version and Platform (required):

  • Binary Ninja Version: 5.1.8005
  • Edition: Commercial
  • OS: Ubuntu Linux
  • OS Version: 24
  • CPU Architecture: x64

Bug Description:

Crashed because of unicode decode error.

Steps To Reproduce:

Python 3.12.4 (main, Jul 25 2024, 22:42:01) [Clang 18.1.8 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 9.4.0 -- An enhanced Interactive Python. Type '?' for help.
Tip: You can use Ctrl-O to force a new line in terminal IPython

In [1]: import binaryninja

In [2]: bv = binaryninja.load("/usr/lib/x86_64-linux-gnu/libQt6Quick.so.6")

In [3]: for dv in bv.data_vars.values():
   ...:     foo = dv.name
---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
<ipython-input-3-2af7a19e6385> in ?()
      1 for dv in bv.data_vars.values():
----> 2     foo = dv.name

/mnt/tide_comes_in_tide_goes_out_you_cant_explain_that/magnets_how_do_they_work/binaryninja/binaryninja/python/binaryninja/binaryview.py in ?(self)
  11311         @property
  11312         def name(self) -> Optional[str]:
  11313                 if self.symbol is None:
  11314                         return None
> 11315                 return self.symbol.name

/mnt/tide_comes_in_tide_goes_out_you_cant_explain_that/magnets_how_do_they_work/binaryninja/binaryninja/python/binaryninja/types.py in ?(self)
    339         @property
    340         def name(self) -> str:
    341                 """Symbol name (read-only)"""
--> 342                 return core.BNGetSymbolRawName(self._handle)

/mnt/tide_comes_in_tide_goes_out_you_cant_explain_that/magnets_how_do_they_work/binaryninja/binaryninja/python/binaryninja/_binaryninjacore.py in ?(sym)
  42501         result = _BNGetSymbolRawName(sym)
  42502         casted = ctypes.cast(result, ctypes.c_char_p).value
  42503         if casted is None:
  42504                 return None
> 42505         string = str(pyNativeStr(casted))
  42506         BNFreeString(result)
  42507         return string

/mnt/tide_comes_in_tide_goes_out_you_cant_explain_that/magnets_how_do_they_work/binaryninja/binaryninja/python/binaryninja/_binaryninjacore.py in ?(arg)
     32 def pyNativeStr(arg: AnyStr) -> str:
     33         if isinstance(arg, str):
     34                 return arg
     35         else:
---> 36                 return arg.decode('utf8')

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe8 in position 12: invalid continuation byte

In [4]: binaryninja.core_version_info()
Out[4]: CoreVersionInfo(major=5, minor=1, build=8005, channel='Stable')

Expected Behavior:
data_var.name doesn't cause unicode error

Screenshots/Video Recording:
N/A

Binary:

blazing guard blazes persistently

Additional Information:

Please add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions