From 271b46974dda6b561446d7aeeb2d7df6171e15d8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 7 Dec 2023 12:40:42 +0100 Subject: [PATCH] [Lifter] Fix escaping/purging of nullbytes (#365) * Create draft PR for #364 * Fix: 0 at end --------- Co-authored-by: NeoQuix Co-authored-by: Spartak Ehrlich Co-authored-by: Niklas Bergmann <97505753+0x6e62@users.noreply.github.com> --- decompiler/frontend/binaryninja/handlers/globals.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/decompiler/frontend/binaryninja/handlers/globals.py b/decompiler/frontend/binaryninja/handlers/globals.py index ee2b5f958..50e54af77 100644 --- a/decompiler/frontend/binaryninja/handlers/globals.py +++ b/decompiler/frontend/binaryninja/handlers/globals.py @@ -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