nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0424-loader-xnu-Check-if-pointer-is-NULL-before-using-it.patch

468bd4
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
468bd4
From: Paulo Flabiano Smorigo <pfsmorigo@canonical.com>
468bd4
Date: Mon, 30 Nov 2020 10:36:00 -0300
468bd4
Subject: [PATCH] loader/xnu: Check if pointer is NULL before using it
468bd4
468bd4
Fixes: CID 73654
468bd4
468bd4
Signed-off-by: Paulo Flabiano Smorigo <pfsmorigo@canonical.com>
468bd4
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
468bd4
---
468bd4
 grub-core/loader/xnu.c | 8 ++++----
468bd4
 1 file changed, 4 insertions(+), 4 deletions(-)
468bd4
468bd4
diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c
09e3cc
index af885a648..49641b8bb 100644
468bd4
--- a/grub-core/loader/xnu.c
468bd4
+++ b/grub-core/loader/xnu.c
468bd4
@@ -671,6 +671,9 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile,
468bd4
   char *name, *nameend;
468bd4
   int namelen;
468bd4
 
468bd4
+  if (infoplistname == NULL)
468bd4
+    return grub_error (GRUB_ERR_BAD_FILENAME, N_("missing p-list filename"));
468bd4
+
468bd4
   name = get_name_ptr (infoplistname);
468bd4
   nameend = grub_strchr (name, '/');
468bd4
 
468bd4
@@ -702,10 +705,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile,
468bd4
   else
468bd4
     macho = 0;
468bd4
 
468bd4
-  if (infoplistname)
468bd4
-    infoplist = grub_file_open (infoplistname, GRUB_FILE_TYPE_XNU_INFO_PLIST);
468bd4
-  else
468bd4
-    infoplist = 0;
468bd4
+  infoplist = grub_file_open (infoplistname, GRUB_FILE_TYPE_XNU_INFO_PLIST);
468bd4
   grub_errno = GRUB_ERR_NONE;
468bd4
   if (infoplist)
468bd4
     {