Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP5:Update
grub2.22049
0008-efi-Fix-gcc9-error-Waddress-of-packed-memb...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0008-efi-Fix-gcc9-error-Waddress-of-packed-member.patch of Package grub2.22049
From bc4cf27b85179806ee859e574293ee014abc7a70 Mon Sep 17 00:00:00 2001 From: Michael Chang <mchang@suse.com> Date: Thu, 11 Apr 2019 17:14:09 +0800 Subject: [PATCH 8/8] 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> --- grub-core/kern/efi/efi.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index d467785fc..a1ab7191a 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -360,6 +360,7 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) { grub_efi_file_path_device_path_t *fp; grub_efi_uint16_t len; + grub_efi_char16_t *dup_name; *p++ = '/'; @@ -370,7 +371,16 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) while (len > 0 && fp->path_name[len - 1] == 0) len--; - p = (char *) grub_utf16_to_utf8 ((unsigned char *) p, fp->path_name, len); + dup_name = grub_malloc (len * sizeof (*dup_name)); + if (!dup_name) + { + grub_free (name); + return NULL; + } + p = (char *) grub_utf16_to_utf8 ((unsigned char *) p, + grub_memcpy (dup_name, fp->path_name, len * sizeof (*dup_name)), + len); + grub_free (dup_name); } dp = GRUB_EFI_NEXT_DEVICE_PATH (dp); @@ -800,9 +810,20 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) fp = (grub_efi_file_path_device_path_t *) dp; buf = grub_malloc ((len - 4) * 2 + 1); if (buf) - *grub_utf16_to_utf8 (buf, fp->path_name, + { + grub_efi_char16_t *dup_name = grub_malloc (len - 4); + if (!dup_name) + { + grub_errno = GRUB_ERR_NONE; + grub_printf ("/File((null))"); + grub_free (buf); + break; + } + *grub_utf16_to_utf8 (buf, grub_memcpy (dup_name, fp->path_name, len - 4), (len - 4) / sizeof (grub_efi_char16_t)) - = '\0'; + = '\0'; + grub_free (dup_name); + } else grub_errno = GRUB_ERR_NONE; grub_printf ("/File(%s)", buf); -- 2.26.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor