Fix a segfault in lsefi
authorRob Clark <rclark@redhat.com>
Wed, 19 Jul 2017 19:47:41 +0000 (15:47 -0400)
committerDaniel Kiper <daniel.kiper@oracle.com>
Thu, 3 Aug 2017 18:03:09 +0000 (20:03 +0200)
when protocols_per_handle returns error, we can't use the pointers we
passed to it, and that includes trusting num_protocols.

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/efi/lsefi.c

index d901c38..d1ce99a 100644 (file)
@@ -109,8 +109,10 @@ grub_cmd_lsefi (grub_command_t cmd __attribute__ ((unused)),
 
       status = efi_call_3 (grub_efi_system_table->boot_services->protocols_per_handle,
                           handle, &protocols, &num_protocols);
-      if (status != GRUB_EFI_SUCCESS)
+      if (status != GRUB_EFI_SUCCESS) {
        grub_printf ("Unable to retrieve protocols\n");
+       continue;
+      }
       for (j = 0; j < num_protocols; j++)
        {
          for (k = 0; k < ARRAY_SIZE (known_protocols); k++)