Fix a segfault in lsefi

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>
This commit is contained in:
Rob Clark 2017-07-19 15:47:41 -04:00 committed by Daniel Kiper
parent 68d54b55f4
commit e8ab5a1a9e

View 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, status = efi_call_3 (grub_efi_system_table->boot_services->protocols_per_handle,
handle, &protocols, &num_protocols); handle, &protocols, &num_protocols);
if (status != GRUB_EFI_SUCCESS) if (status != GRUB_EFI_SUCCESS) {
grub_printf ("Unable to retrieve protocols\n"); grub_printf ("Unable to retrieve protocols\n");
continue;
}
for (j = 0; j < num_protocols; j++) for (j = 0; j < num_protocols; j++)
{ {
for (k = 0; k < ARRAY_SIZE (known_protocols); k++) for (k = 0; k < ARRAY_SIZE (known_protocols); k++)