124a375
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
749be47
From: Javier Martinez Canillas <javierm@redhat.com>
749be47
Date: Mon, 16 Mar 2020 13:51:45 +0100
124a375
Subject: [PATCH] blscfg: return NULL instead of a zero-length array in
749be47
 bls_make_list()
749be47
749be47
The bls_make_list() function returns a list of all the values for a given
749be47
key and if there is none a NULL pointer should be returned. But currently
749be47
is returnin a zero-length array instead.
749be47
749be47
This makes the callers to wrongly assume that there are values for a key
749be47
and populate wrong menu entries. For example menu entries are populated
749be47
with an initrd command even if there is no initrd fiel in the BLS file.
749be47
749be47
Resolves: rhbz#1806022
749be47
749be47
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
749be47
---
749be47
 grub-core/commands/blscfg.c | 6 ++++++
749be47
 1 file changed, 6 insertions(+)
749be47
749be47
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
749be47
index aa4e624905e..df6947f58cd 100644
749be47
--- a/grub-core/commands/blscfg.c
749be47
+++ b/grub-core/commands/blscfg.c
749be47
@@ -600,6 +600,12 @@ static char **bls_make_list (struct bls_entry *entry, const char *key, int *num)
749be47
       list[nlist] = NULL;
749be47
   }
749be47
 
749be47
+  if (!nlist)
749be47
+    {
749be47
+      grub_free (list);
749be47
+      return NULL;
749be47
+    }
749be47
+
749be47
   if (num)
749be47
     *num = nlist;
749be47