Skip to content

Commit

Permalink
fix: fix kaitai plugin byte and string array sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
hello-adam committed Jun 6, 2022
1 parent e770f65 commit fdc2b10
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/hobbits-plugins/analyzers/KaitaiStruct/scripts/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit fdc2b10

Please sign in to comment.