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

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