Blame SOURCES/0253-Fix-get_entry_number-wrongly-dereferencing-the-tail-.patch

8631a2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8631a2
From: Javier Martinez Canillas <javierm@redhat.com>
8631a2
Date: Tue, 4 Dec 2018 10:53:49 +0100
8631a2
Subject: [PATCH] Fix get_entry_number() wrongly dereferencing the tail pointer
8631a2
8631a2
The get_entry_number_helper() function attempts to lookup a boot entry by
8631a2
either title or id matching the value of an environment variable. If they
8631a2
are a substring of the variable, the tail pointer is set to the first char
8631a2
of the remainder of the string.
8631a2
8631a2
When get_entry_number() calls this function, it checks if this first char
8631a2
is a NUL byte, to know if the variable matched correctly. But tail can be
8631a2
set to NULL as well to indicate that there isn't a remainder in the string.
8631a2
8631a2
Resolves: rhbz#1654936
8631a2
8631a2
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
8631a2
---
8631a2
 grub-core/normal/menu.c | 2 +-
8631a2
 1 file changed, 1 insertion(+), 1 deletion(-)
8631a2
8631a2
diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c
09e3cc
index fc25c702f..7e32c498a 100644
8631a2
--- a/grub-core/normal/menu.c
8631a2
+++ b/grub-core/normal/menu.c
8631a2
@@ -563,7 +563,7 @@ get_entry_number (grub_menu_t menu, const char *name)
8631a2
 
8631a2
   grub_error_push ();
8631a2
   entry = get_entry_number_helper(menu, val, &tail);
8631a2
-  if (*tail != '\0')
8631a2
+  if (tail && *tail != '\0')
8631a2
     entry = -1;
8631a2
   grub_error_pop ();
8631a2