loader/efi/linux: Return correct size from LoadFile
PATCH v2 1/1 loader/efi/linux: Return correct size from LoadFile
From UEFI specifications 2.10, section 13.2.2,
"EFI_LOAD_FILE2_PROTOCOL.LoadFile" (see
https://uefi.org/specs/UEFI/2.10/13_Protocols_Media_Access.html),
for BufferSize:
On input the size of Buffer in bytes. On output with a return code of EFI_SUCCESS, the amount of data transferred to Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL, the size of Buffer required to retrieve the requested file.
so set *buffer_size correctly.
---
Changes since v1:
- improved commit message
--- grub-core/loader/efi/linux.c | 1 + 1 file changed, 1 insertion(+)
grub-core/loader/efi/linux.c +1 -0
@@ -363,6 +363,7 @@ grub_efi_initrd_load_file2 (grub_efi_load_file2_t *this,grub_dprintf ("linux" ,"Providing initrd via EFI_LOAD_FILE2_PROTOCOL\n" ); + *buffer_size = initrd_size;if (grub_initrd_load (&initrd_ctx, buffer)) status =GRUB_EFI_DEVICE_ERROR ;
Signature · 7 lines
2.43.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
Quoted 10 lines · Frediano Ziglio via Grub-devel
From UEFI specifications 2.10, section 13.2.2,
"EFI_LOAD_FILE2_PROTOCOL.LoadFile" (see
https://uefi.org/specs/UEFI/2.10/13_Protocols_Media_Access.html),
for BufferSize:On input the size of Buffer in bytes. On output with a return code of
EFI_SUCCESS, the amount of data transferred to Buffer. On output with a return code ofEFI_BUFFER_TOO_SMALL, the size of Buffer required to retrieve the requested file.
Quoted 6 lines
so set
*buffer_sizecorrectly.Signed-off-by Frediano Ziglio <[email protected]>---
Changes since v1:
- improved commit message
Thank you!
Quoted 9 lines
--- grub-core/loader/efi/linux.c | 1 + 1 file changed, 1 insertion(+)grub-core/loader/efi/linux.c +0
-0
grub-core/loader/efi/linux.c grub_efi_initrd_load_file2 (grub_efi_load_file2_t *this, · line 368
Quoted 6 lines
grub-core/loader/efi/linux.c +1
-0@@ -363,6 +363,7 @@ grub_efi_initrd_load_file2 (grub_efi_load_file2_t *this,grub_dprintf ("linux" ,"Providing initrd via EFI_LOAD_FILE2_PROTOCOL\n" ); + *buffer_size = initrd_size;if (grub_initrd_load (&initrd_ctx, buffer)) status =GRUB_EFI_DEVICE_ERROR ;
IMO code is still not in line with the spec. If you think it is correct it begs for a comment in the code and a blurb in a commit message.
Daniel
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel