grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
To: grub-devel@gnu.org
Cc: nayna@linux.ibm.com, ssrish@linux.ibm.com,
	sridharm@linux.ibm.com,
	Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Subject: [PATCH] menuentry: Fix for out of bound issue
Date: Thu,  9 Oct 2025 14:49:39 +0530	[thread overview]
Message-ID: <20251009091939.33266-1-sudhakar@linux.ibm.com> (raw)

A menu entry with an empty title leads to an out-of-bounds access at
ch = src[len - 1] (i.e., `src` is empty and `len` is zero). So, fixing
this by checking the menu entry title length and throwing an error if
the length is zero.

Signed-off-by: Sridhar Markonda <sridharm@linux.ibm.com>
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
---
 grub-core/commands/menuentry.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/grub-core/commands/menuentry.c b/grub-core/commands/menuentry.c
index 09749c415..e64bfeec7 100644
--- a/grub-core/commands/menuentry.c
+++ b/grub-core/commands/menuentry.c
@@ -266,6 +266,9 @@ grub_cmd_menuentry (grub_extcmd_context_t ctxt, int argc, char **args)
   if (! argc)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing arguments");
 
+  if (! grub_strlen (args[argc - 1]))
+    return grub_error (GRUB_ERR_BAD_ARGUMENT, "menuentry is missing title");
+
   if (ctxt->state[3].set && ctxt->script)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "multiple menuentry definitions");
 
-- 
2.50.1 (Apple Git-155)


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

             reply	other threads:[~2025-10-09  9:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-09  9:19 Sudhakar Kuppusamy [this message]
2025-10-09 13:11 ` [PATCH] menuentry: Fix for out of bound issue 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=20251009091939.33266-1-sudhakar@linux.ibm.com \
    --to=sudhakar@linux.ibm.com \
    --cc=grub-devel@gnu.org \
    --cc=nayna@linux.ibm.com \
    --cc=sridharm@linux.ibm.com \
    --cc=ssrish@linux.ibm.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;
as well as URLs for NNTP newsgroup(s).