grub/grub-core/kern/efi
Michael Chang 35e918e7c9 efi: Fix gcc9 error -Waddress-of-packed-member
The address of fp->path_name could be unaligned since seeking into the
device path buffer for a given node could end in byte boundary.

The fix is allocating aligned buffer by grub_malloc for holding the
UTF16 string copied from fp->path_name, and after using that buffer as
argument for grub_utf16_to_utf8 to convert it to UTF8 string.

[  255s] ../../grub-core/kern/efi/efi.c: In function 'grub_efi_get_filename':
[  255s] ../../grub-core/kern/efi/efi.c:410:60: error: taking address of packed member of 'struct grub_efi_file_path_device_path' may result in an unaligned pointer value [-Werror=address-of-packed-member]
[  255s]   410 |    p = (char *) grub_utf16_to_utf8 ((unsigned char *) p, fp->path_name, len);
[  255s]       |                                                          ~~^~~~~~~~~~~
[  255s] ../../grub-core/kern/efi/efi.c: In function 'grub_efi_print_device_path':
[  255s] ../../grub-core/kern/efi/efi.c:900:33: error: taking address of packed member of 'struct grub_efi_file_path_device_path' may result in an unaligned pointer value [-Werror=address-of-packed-member]
[  255s]   900 |     *grub_utf16_to_utf8 (buf, fp->path_name,
[  255s]       |                               ~~^~~~~~~~~~~

Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-09-21 20:05:48 -04:00
..
acpi.c tsc: Use alternative delay sources whenever appropriate. 2015-11-27 11:39:55 +01:00
efi.c efi: Fix gcc9 error -Waddress-of-packed-member 2020-09-21 20:05:48 -04:00
fdt.c efi: Move fdt helper into own file 2016-11-24 10:09:24 +01:00
init.c efi: Free malloc regions on exit 2020-09-21 12:16:25 -04:00
mm.c arm64/efi: Fix grub_efi_get_ram_base() 2020-09-21 16:43:54 -04:00
tpm.c Remove the deprecated 'Event' struct 2017-11-08 09:45:39 +00:00