From 3dffa8145fb90acbbe9778f9c3655e262829bc23 Mon Sep 17 00:00:00 2001 From: Willi Ballenthin Date: Wed, 27 Sep 2023 08:47:52 +0200 Subject: [PATCH] Update capa/features/extractors/binja/helpers.py --- capa/features/extractors/binja/helpers.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/capa/features/extractors/binja/helpers.py b/capa/features/extractors/binja/helpers.py index b19ffa9f..a0a04da6 100644 --- a/capa/features/extractors/binja/helpers.py +++ b/capa/features/extractors/binja/helpers.py @@ -54,9 +54,8 @@ def unmangle_c_name(name: str) -> str: def read_c_string(bv: BinaryView, offset: int, max_len: int) -> str: - s = "" - count = 0 - while count < max_len: + s = [] + while len(s) < max_len: try: c = bv.read(offset + count, 1)[0] except Exception: @@ -65,7 +64,6 @@ def read_c_string(bv: BinaryView, offset: int, max_len: int) -> str: if c == 0: break - s += chr(c) - count += 1 + s.append(chr(c)) - return s + return "".join(s)