From 0c0dd317735f80c83b841f04d18150462818f256 Mon Sep 17 00:00:00 2001 From: Ricardo Baratto Date: Tue, 4 Feb 2025 15:39:33 -0500 Subject: [PATCH 1/2] fix infinite recursion when no stack offset present in variable introduction this also fixes how we handle a stack variable introduction without an offset. Before we would issue a warning, then raise the non-positive error. This switches it to raising an error if the offset is not there, and also issue an error if the values is non-positive --- chb/userdata/UserHints.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/chb/userdata/UserHints.py b/chb/userdata/UserHints.py index 8380fdef..866dd7e9 100644 --- a/chb/userdata/UserHints.py +++ b/chb/userdata/UserHints.py @@ -529,15 +529,16 @@ def offset(self) -> int: """ if not "offset" in self.varintro: - chklogger.logger.warning( - "Stack variable intro without offset; returning 0") - index = int(self.varintro.get("offset", "0")) + raise UF.CHBError( + "Stack variable intro without offset") + + index = int(self.varintro["offset"]) if index > 0: return -index else: raise UF.CHBError( "Unexpected non-positive offset in stack-variable intro: " - + str(self.offset)) + + str(index)) @property def name(self) -> str: From 5b923b8050b910c12ea967bb438b097c52ed3ed5 Mon Sep 17 00:00:00 2001 From: Ricardo Baratto Date: Tue, 4 Feb 2025 15:54:59 -0500 Subject: [PATCH 2/2] some fixes for ARMStoreRegisterHalfword - If hitting the right path, lhs was potentially unbound. This makes it None in that path and we check for it - The ll_assigns and hl_assigns variable were showing up as unused. I switched things over to use them as the return value --- chb/arm/opcodes/ARMStoreRegisterHalfword.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chb/arm/opcodes/ARMStoreRegisterHalfword.py b/chb/arm/opcodes/ARMStoreRegisterHalfword.py index 6d6cd45e..c2bf3bb4 100644 --- a/chb/arm/opcodes/ARMStoreRegisterHalfword.py +++ b/chb/arm/opcodes/ARMStoreRegisterHalfword.py @@ -194,6 +194,7 @@ def ast_prov( lhs, xdata, iaddr, astree, memaddr=memaddr) elif xd.is_vmem_unknown and xd.is_address_known: + lhs = None memaddr = xd.xaddr hl_lhs = XU.xmemory_dereference_lval(memaddr, xdata, iaddr, astree) @@ -216,7 +217,7 @@ def ast_prov( bytestring=bytestring, annotations=annotations) - if lhs.is_tmp: + if lhs is not None and lhs.is_tmp: astree.add_expose_instruction(hl_assign.instrid) astree.add_instr_mapping(hl_assign, ll_assign) astree.add_instr_address(hl_assign, [iaddr]) @@ -265,4 +266,4 @@ def ast_prov( ll_assigns = [ll_assign] hl_assigns = [hl_assign] - return ([hl_assign], [ll_assign]) + return (hl_assigns, ll_assigns)