]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
efi: explicitly cast physical address to UINTN when converting to/from pointers 5593/head
authorLennart Poettering <lennart@poettering.net>
Tue, 29 May 2018 15:12:39 +0000 (17:12 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 31 May 2018 14:10:46 +0000 (16:10 +0200)
UINTN is the integer type equalling the native ptr size. Let's fix the
casting warnings described in #7788 by casting the the pointers and
values to this type first. That way we cast integers to the right size
first before turning them into pointers, and pointers are first
covnerted to integers of the right size before converting them into
integers.

Not tested, since I lack i386 EFI systems, but I think this is simple
enough to be correct event without testing.

Fixes: #7788
src/boot/efi/boot.c
src/boot/efi/linux.c
src/boot/efi/stub.c

index cc8fe6b641dfe1745b0a1d67f4fa29ab1dd15e37..72a946b1ad35cbbe3279e1f3c4cd161588ea50c0 100644 (file)
@@ -1676,7 +1676,7 @@ static EFI_STATUS image_start(EFI_HANDLE parent_image, const Config *config, con
 #if ENABLE_TPM
                 /* Try to log any options to the TPM, especially to catch manually edited options */
                 err = tpm_log_event(SD_TPM_PCR,
-                                    (EFI_PHYSICAL_ADDRESS) loaded_image->LoadOptions,
+                                    (EFI_PHYSICAL_ADDRESS) (UINTN) loaded_image->LoadOptions,
                                     loaded_image->LoadOptionsSize, loaded_image->LoadOptions);
                 if (EFI_ERROR(err)) {
                         Print(L"Unable to add image options measurement: %r", err);
index e8f7651324f139f1a085034dc544428355c600fe..1f81f3e771293d867565fefb2310e85a0bf73b27 100644 (file)
@@ -128,7 +128,7 @@ EFI_STATUS linux_exec(EFI_HANDLE *image,
                 if (EFI_ERROR(err))
                         return err;
                 CopyMem((VOID *)(UINTN)addr, cmdline, cmdline_len);
-                ((CHAR8 *)addr)[cmdline_len] = 0;
+                ((CHAR8 *)(UINTN)addr)[cmdline_len] = 0;
                 boot_setup->cmd_line_ptr = (UINT32)addr;
         }
 
index f368a673512ffe829dcea52d790f67e0f76b7fc3..c107a07ee7400c186902d438640a8480693ea35e 100644 (file)
@@ -90,7 +90,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
 #if ENABLE_TPM
                 /* Try to log any options to the TPM, especially manually edited options */
                 err = tpm_log_event(SD_TPM_PCR,
-                                    (EFI_PHYSICAL_ADDRESS) loaded_image->LoadOptions,
+                                    (EFI_PHYSICAL_ADDRESS) (UINTN) loaded_image->LoadOptions,
                                     loaded_image->LoadOptionsSize, loaded_image->LoadOptions);
                 if (EFI_ERROR(err)) {
                         Print(L"Unable to add image options measurement: %r", err);