[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] loongarch: Avoid undefined behavior when popping from an emp
From: |
Daniel Kiper |
Subject: |
Re: [PATCH] loongarch: Avoid undefined behavior when popping from an empty reloc stack |
Date: |
Fri, 19 May 2023 15:21:28 +0200 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
On Thu, May 18, 2023 at 10:52:57AM +0800, WANG Xuerui wrote:
> The return value of grub_loongarch64_stack_pop is unsigned, so -1 should
> not be used in the first place. Replacing with 0 is enough to avoid the
> UB in this edge case.
>
> Technically though, proper error handling is needed throughout the
> management of the reloc stack, so no unexpected behavior will happen
> even in case of malformed object code input (right now, pushes become
> no-ops when the stack is full, and garbage results if the stack does not
> contain enough operands for an op). The refactor would touch some more
> places so would be best done in a separate series.
>
> Fixes: CID 407777
> Fixes: CID 407778
>
> Signed-off-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Daniel