1f092ca
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
1f092ca
From: Javier Martinez Canillas <javierm@redhat.com>
1f092ca
Date: Fri, 30 Nov 2018 16:39:09 +0100
1f092ca
Subject: [PATCH] Fix menu entry selection based on title
1f092ca
1f092ca
The get_entry_number_helper() function assumes that there could be a set
1f092ca
of entries identifiers in a variable (i.e: as used in the fallback case)
1f092ca
so iterates over the string until it finds a space to get the first id.
1f092ca
1f092ca
But this should only be done for indexes or entries id, since the title
1f092ca
can contain spaces. In the case of title, the complete string should be
1f092ca
used to select a given entry.
1f092ca
1f092ca
Resolves: rhbz#1654936
1f092ca
1f092ca
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
1f092ca
---
1f092ca
 grub-core/normal/menu.c | 7 ++-----
1f092ca
 1 file changed, 2 insertions(+), 5 deletions(-)
1f092ca
1f092ca
diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
1f092ca
index 95f7abaf2fd..fc25c702f3c 100644
1f092ca
--- a/grub-core/normal/menu.c
1f092ca
+++ b/grub-core/normal/menu.c
1f092ca
@@ -217,14 +217,11 @@ get_entry_number_helper(grub_menu_t menu,
1f092ca
 
1f092ca
   for (i = 0, e = menu->entry_list; e; i++)
1f092ca
     {
1f092ca
-      int l = 0;
1f092ca
-      while (val[l] && !grub_isspace(val[l]))
1f092ca
-	l++;
1f092ca
 
1f092ca
-      if (menuentry_eq (e->title, val, l))
1f092ca
+      if (menuentry_eq (e->title, val, -1))
1f092ca
 	{
1f092ca
 	  if (tail)
1f092ca
-	    *tail = val + l;
1f092ca
+	    *tail = NULL;
1f092ca
 	  return i;
1f092ca
 	}
1f092ca
       e = e->next;