Blame SOURCES/0346-verifiers-Fix-calling-uninitialized-function-pointer.patch

5975ab
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
5975ab
From: Michael Chang <mchang@suse.com>
5975ab
Date: Tue, 18 Feb 2020 18:08:18 +0800
5975ab
Subject: [PATCH] verifiers: Fix calling uninitialized function pointer
5975ab
5975ab
The necessary check for NULL before use of function ver->close is not
5975ab
taking place in the failure path. This patch simply adds the missing
5975ab
check and fixes the problem that GRUB hangs indefinitely after booting
5975ab
rogue image without valid signature if secure boot is turned on.
5975ab
5975ab
Now it displays like this for booting rogue UEFI image:
5975ab
5975ab
  error: bad shim signature
5975ab
  error: you need to load the kernel first
5975ab
5975ab
  Press any key to continue...
5975ab
5975ab
and then you can go back to boot menu by pressing any key or after a few
5975ab
seconds expired.
5975ab
5975ab
Signed-off-by: Michael Chang <mchang@suse.com>
5975ab
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
5975ab
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
5975ab
---
5975ab
 grub-core/commands/verifiers.c | 3 ++-
5975ab
 1 file changed, 2 insertions(+), 1 deletion(-)
5975ab
5975ab
diff --git a/grub-core/commands/verifiers.c b/grub-core/commands/verifiers.c
09e3cc
index c638d5f43..599d79b75 100644
5975ab
--- a/grub-core/commands/verifiers.c
5975ab
+++ b/grub-core/commands/verifiers.c
5975ab
@@ -196,7 +196,8 @@ grub_verifiers_open (grub_file_t io, enum grub_file_type type)
5975ab
   return ret;
5975ab
 
5975ab
  fail:
5975ab
-  ver->close (context);
5975ab
+  if (ver->close)
5975ab
+    ver->close (context);
5975ab
  fail_noclose:
5975ab
   verified_free (verified);
5975ab
   grub_free (ret);