From fdc2b10c373a66c110488026e3b130ee47e5d65e Mon Sep 17 00:00:00 2001 From: Adam Nash Date: Mon, 6 Jun 2022 16:05:55 -0400 Subject: [PATCH] fix: fix kaitai plugin byte and string array sizes --- .../analyzers/KaitaiStruct/scripts/runner.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/hobbits-plugins/analyzers/KaitaiStruct/scripts/runner.py b/src/hobbits-plugins/analyzers/KaitaiStruct/scripts/runner.py index 9342356f..016e9540 100644 --- a/src/hobbits-plugins/analyzers/KaitaiStruct/scripts/runner.py +++ b/src/hobbits-plugins/analyzers/KaitaiStruct/scripts/runner.py @@ -19,16 +19,17 @@ def process_value(value, section): if isinstance(value, bytes): if len(value) > 15: - value = f"0x{binascii.hexlify(value[:12]).decode()}..." + str_val = f"0x{binascii.hexlify(value[:12]).decode()}..." else: - value = f"0x{binascii.hexlify(value).decode()}" - section['value'] = value + str_val = f"0x{binascii.hexlify(value).decode()}" + section['value'] = str_val section['type'] = f"bytes[{len(value)}]" elif isinstance(value, str): + str_val = value if len(value) > 15: - value = f"{value[:12]}..." - section['value'] = value + str_val = f"{value[:12]}..." + section['value'] = str_val section['type'] = f"str[{len(value)}]" elif isinstance(value, float): @@ -78,6 +79,9 @@ def parse_struct(struct, sections, prefix="", parent_offset = 0, base_io=None, b base_io = section_io base_offset = base_offset + parent_offset print(f"New base offset for {type(struct).__name__}: {base_offset}") + + #print(vars(struct)) + #print(struct._debug) for name, info in struct._debug.items(): try: