diff options
| author | Peter Jones <pjones@redhat.com> | 2019-11-18 13:58:46 -0500 |
|---|---|---|
| committer | Peter Jones <pjones@redhat.com> | 2020-07-23 20:53:24 -0400 |
| commit | 959f5e4e993a82020fef48c7e7c012a44074645c (patch) | |
| tree | e79fc1afcf781431e1a0790867be1df91497792c | |
| parent | 5e6e0792cedb3b71cbe061ae56e96906cf710579 (diff) | |
| download | efi-boot-shim-959f5e4e993a82020fef48c7e7c012a44074645c.tar.gz efi-boot-shim-959f5e4e993a82020fef48c7e7c012a44074645c.zip | |
Actually check for errors from set_second_stage()
This changes shim_init() to check for errors from set_second_stage().
In order to make that work, it also does the following:
- correctly /always/ allocate second_stage, not sometimes allocate and
sometimes point at .data
- test for LoadOptionSize == 0 and return success
- print an error message for the failure so we can see it.
Signed-off-by: Peter Jones <pjones@redhat.com>
Upstream-commit-id: 354bd9b1931
| -rw-r--r-- | shim.c | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -2141,8 +2141,15 @@ EFI_STATUS set_second_stage (EFI_HANDLE image_handle) CHAR16 *loader_str = NULL; UINTN loader_len = 0; unsigned int i; + UINTN second_stage_len; - second_stage = DEFAULT_LOADER; + second_stage_len = StrLen(DEFAULT_LOADER) + 1; + second_stage = AllocatePool(second_stage_len); + if (!second_stage) { + perror(L"Could not allocate %lu bytes\n", second_stage_len); + return EFI_OUT_OF_RESOURCES; + } + StrCpy(second_stage, DEFAULT_LOADER); load_options = NULL; load_options_size = 0; @@ -2200,6 +2207,12 @@ EFI_STATUS set_second_stage (EFI_HANDLE image_handle) */ /* + * Maybe there just aren't any options... + */ + if (li->LoadOptionsSize == 0) + return EFI_SUCCESS; + + /* * In either case, we've got to have at least a UCS2 NUL... */ if (li->LoadOptionsSize < 2) @@ -2465,7 +2478,11 @@ shim_init(void) dprint(L"%a", shim_version); /* Set the second stage loader */ - set_second_stage (global_image_handle); + efi_status = set_second_stage(global_image_handle); + if (EFI_ERROR(efi_status)) { + perror(L"set_second_stage() failed: %r\n", efi_status); + return efi_status; + } if (secure_mode()) { if (vendor_cert_size || vendor_dbx_size) { |
