Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Preprocessing] Stack canary check found in __stack_chk_fail #244

7 changes: 2 additions & 5 deletions decompiler/pipeline/preprocessing/remove_stack_canary.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RemoveStackCanary(PipelineStage):
STACK_FAIL_STR = "__stack_chk_fail"

def run(self, task: DecompilerTask):
if task.options.getboolean(f"{self.name}.remove_canary", fallback=False):
if task.options.getboolean(f"{self.name}.remove_canary", fallback=False) and task.name != self.STACK_FAIL_STR:
self._cfg = task.graph
for fail_node in list(self._contains_stack_check_fail()):
self._patch_canary(fail_node)
Expand All @@ -36,10 +36,7 @@ def _is_stack_chk_fail(self, node: BasicBlock) -> bool:
"""
Check if node contains call to __stack_chk_fail
"""
for instr in [str(i) for i in node.instructions]:
if self.STACK_FAIL_STR in instr:
return True
return False
return any(self.STACK_FAIL_STR in str(inst) for inst in node.instructions)

def _patch_canary(self, node: BasicBlock):
"""
Expand Down
Loading