Re: [PATCH] blsuki: Fix grub_errno leakage in blsuki_is_default_entry()

Michael Chang via Grub-devel <[email protected]>
Newsgroups org.gnu.grub-devel
Message-ID <5hhm3oxqdxtkt4yd2ow7ufjuv5aymxufgvwekpiztggswzex3q@cezzhutfdssu>
Hi,

Sorry. Forgot to mention the downstream bug report which was fixed by
the patch.

https://bugzilla.suse.com/show_bug.cgi?id=1253097

Thanks,
Michael

On Mon, Nov 10, 2025 at 03:38:13PM +0800, Michael Chang wrote:
> The grub_strtol() call in blsuki_is_default_entry() can set grub_errno
> to GRUB_ERR_BAD_NUMBER if the input string cannot be converted into any
> valid digits.
> 
> This errno value is currently left uncleared, which can lead to
> unexpected behavior in subsequent logic that tests the result of a
> function by checking grub_errno.
> 
> Clear grub_errno and return false when GRUB_ERR_BAD_NUMBER is set, as
> this specific error should be ignored in this context.
> 
> Signed-off-by: Michael Chang <[email protected]>
> ---
>  grub-core/commands/blsuki.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/grub-core/commands/blsuki.c b/grub-core/commands/blsuki.c
> index 21d767f05..df25b6fbc 100644
> --- a/grub-core/commands/blsuki.c
> +++ b/grub-core/commands/blsuki.c
> @@ -1510,6 +1510,12 @@ blsuki_is_default_entry (const char *def_entry, grub_blsuki_entry_t *entry, int
>      return true;
>  
>    def_idx = grub_strtol (def_entry, &def_entry_end, 0);
> +  if (grub_errno == GRUB_ERR_BAD_NUMBER)
> +    {
> +      grub_errno = GRUB_ERR_NONE;
> +      return false;
> +    }
> +
>    if (*def_entry_end != '\0' || def_idx < 0 || def_idx > GRUB_INT_MAX)
>      return false;
>  
> -- 
> 2.51.1
> 

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.