From: Michael Chang via Grub-devel <grub-devel@gnu.org>
To: The development of GNU GRUB <grub-devel@gnu.org>
Cc: Michael Chang <mchang@suse.com>
Subject: [PATCH] blsuki: Fix grub_errno leakage in blsuki_is_default_entry()
Date: Mon, 10 Nov 2025 15:38:13 +0800 [thread overview]
Message-ID: <20251110073813.20146-1-mchang@suse.com> (raw)
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 <mchang@suse.com>
---
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
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
next reply other threads:[~2025-11-10 7:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 7:38 Michael Chang via Grub-devel [this message]
2025-11-10 13:35 ` [PATCH] blsuki: Fix grub_errno leakage in blsuki_is_default_entry() Sudhakar Kuppusamy
2025-11-11 4:38 ` Michael Chang via Grub-devel
2025-11-10 14:55 ` Michael Lawnick via Grub-devel
2025-11-11 4:18 ` Michael Chang via Grub-devel
2025-11-10 17:26 ` Alec Brown via Grub-devel
2025-11-11 4:36 ` Michael Chang via Grub-devel
2025-11-11 4:21 ` Michael Chang via Grub-devel
[not found] <mailman.2112.1762781770.1058.grub-devel@gnu.org>
2025-11-10 15:04 ` Avnish Chouhan
2025-11-11 4:37 ` Michael Chang via Grub-devel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251110073813.20146-1-mchang@suse.com \
--to=grub-devel@gnu.org \
--cc=mchang@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox