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

Michael Chang via Grub-devel <[email protected]>
Newsgroups org.gnu.grub-devel
Message-ID <kbddbqtpsswr2d7v4rloyasqjyzniuzmqmmutsv64pcot2blrk@ylmnozba66iz>
On Wed, Nov 12, 2025 at 02:56:01PM +0000, Alec Brown wrote:
> On Tue, Nov 11, 2025 at 1:49 AM, Michael Chang <[email protected]> wrote:
> > The grub_strtol() call in blsuki_is_default_entry() can set grub_errno
> > to either GRUB_ERR_BAD_NUMBER or GRUB_ERR_OUT_OF_RANGE if the input
> > string is invalid or out of range.
> > 
> > This errno value is currently left uncleared, which can lead to
> > unexpected behavior in subsequent functions that rely on checking
> > current state of grub_errno.
> > 
> > Clear grub_errno and return false when GRUB_ERR_BAD_NUMBER or
> > GRUB_ERR_OUT_OF_RANGE is encountered. This ensures that the error is
> > handled as false return and no grub_errno leakage.
> > 
> > Signed-off-by: Michael Chang <[email protected]>
> > Reviewed-by: Sudhakar Kuppusamy <[email protected]>
> > Reviewed-by: Avnish Chouhan <[email protected]>
> 
> This patch LGTM! Thanks!
> 
> Reviewed-by: Alec Brown <[email protected]>

Thank you. I'll add your Reviewed-by in next version.

Regards,
Michael

> 
> Alec Brown
> 
> > ---
> >  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..8a3446336 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_OUT_OF_RANGE)
> > +    {
> > +      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://urldefense.com/v3/__https://lists.gnu.org/mailman/listinfo/grub-
> > devel__;!!ACWV5N9M2RV99hQ!JIG53ZDSKnYgydE5bCbUWvMzihp8OvCOcXwfI3AmtgX7S1zlAaNAl8X-
> > RzxZMpUSUmnK8nZqqyDEemhqbGBh$

_______________________________________________
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.