Skip to contentSkip to conversation

menuentry: Fix for out of bound issue

PATCH In review Sudhakar Kuppusamy 2 participants 2 messages Oct 9, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 menuentry: Fix for out of bound issue

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.

---
 grub-core/commands/menuentry.c | 3 +++
 1 file changed, 3 insertions(+)
grub-core/commands/menuentry.c +3 -0
index 09749c415..e64bfeec7 100644
@@ -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");
 
Signature · 7 lines
2.50.1 (Apple Git-155)


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Reviewed-by on v1 1/1
#1 lore raw

On Thu, Oct 09, 2025 at 02:49:39PM +0530, Sudhakar Kuppusamy wrote:

Missing "From: Sridhar Markonda <[email protected]>"...

I will add it for you...

Quoted 7 lines

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.

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel