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 v3] blsuki: Fix grub_errno leakage in blsuki_is_default_entry()
Date: Tue, 18 Nov 2025 16:04:48 +0800 [thread overview]
Message-ID: <20251118080448.545999-1-mchang@suse.com> (raw)
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_strtol() reports error. This
ensures that the error is handled and no grub_errno leakage.
Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Reviewed-by: Avnish Chouhan <avnish@linux.ibm.com>
Reviewed-by: Alec Brown <alec.r.brown@oracle.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..9abb39a74 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_NONE)
+ {
+ 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-18 8:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-18 8:04 Michael Chang via Grub-devel [this message]
2025-11-19 20:26 ` [PATCH v3] blsuki: Fix grub_errno leakage in blsuki_is_default_entry() Daniel Kiper
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=20251118080448.545999-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.