]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
verifiers: Fix calling uninitialized function pointer
authorMichael Chang <mchang@suse.com>
Tue, 18 Feb 2020 10:08:18 +0000 (18:08 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 18 Feb 2020 14:17:40 +0000 (15:17 +0100)
The necessary check for NULL before use of function ver->close is not
taking place in the failure path. This patch simply adds the missing
check and fixes the problem that GRUB hangs indefinitely after booting
rogue image without valid signature if secure boot is turned on.

Now it displays like this for booting rogue UEFI image:

  error: bad shim signature
  error: you need to load the kernel first

  Press any key to continue...

and then you can go back to boot menu by pressing any key or after a few
seconds expired.

Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/verifiers.c

index 0dde4818267abc01d5e0728828c4ba9c11c8820f..7b9297cd345d8142ce76137233049e9ce44a62de 100644 (file)
@@ -196,7 +196,8 @@ grub_verifiers_open (grub_file_t io, enum grub_file_type type)
   return ret;
 
  fail:
-  ver->close (context);
+  if (ver->close)
+    ver->close (context);
  fail_noclose:
   verified_free (verified);
   grub_free (ret);