nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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