Skip to content

Commit

Permalink
[Lifter] Fix escaping/purging of nullbytes (#365)
Browse files Browse the repository at this point in the history
* Create draft PR for #364

* Fix: 0 at end

---------

Co-authored-by: NeoQuix <[email protected]>
Co-authored-by: Spartak Ehrlich <[email protected]>
Co-authored-by: Niklas Bergmann <[email protected]>
  • Loading branch information
4 people authored Dec 7, 2023
1 parent 882b78c commit 271b469
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions decompiler/frontend/binaryninja/handlers/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def _lift_constant_type(
) -> StringSymbol:
"""Lift constant data type (bninja only uses strings) into code""" # jump table ist auch constant
if str(variable).find("char const") != -1:
string = str(variable.value)[2:-1].rstrip(
"\\x00"
) # we want to keep escaped control chars (\n), therefore we take the raw string representation of bytes and purge b""
string = str(variable.value.rstrip(b"\x00"))[
2:-1
] # we want to keep escaped control chars (\n), therefore we take the raw string representation of bytes and purge b""
return StringSymbol(f'"{string}"', variable.address, vartype=Pointer(Integer.char(), view.address_size * BYTE_SIZE))
return StringSymbol(
f"&{variable.name}" if variable.name else GLOBAL_VARIABLE_PREFIX + f"{variable.address:x}", variable.address
Expand Down

0 comments on commit 271b469

Please sign in to comment.