dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0240-Clean-up-some-errors-in-the-linuxefi-loader.patch

27a4da
From 444dd65bf9b5655afd4a32d71fa9d22a5b46caa2 Mon Sep 17 00:00:00 2001
27a4da
From: Peter Jones <pjones@redhat.com>
27a4da
Date: Wed, 24 May 2017 15:58:18 -0400
27a4da
Subject: [PATCH 240/260] Clean up some errors in the linuxefi loader
27a4da
27a4da
Signed-off-by: Peter Jones <pjones@redhat.com>
27a4da
---
27a4da
 grub-core/loader/i386/efi/linux.c | 18 +++++++++---------
27a4da
 1 file changed, 9 insertions(+), 9 deletions(-)
27a4da
27a4da
diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c
27a4da
index 52dc71903..19950d2f2 100644
27a4da
--- a/grub-core/loader/i386/efi/linux.c
27a4da
+++ b/grub-core/loader/i386/efi/linux.c
27a4da
@@ -161,8 +161,8 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
27a4da
 		int argc, char *argv[])
27a4da
 {
27a4da
   grub_file_t file = 0;
27a4da
-  struct linux_kernel_header *lh;
27a4da
-  grub_ssize_t len, start, filelen;
27a4da
+  struct linux_kernel_header *lh = NULL;
27a4da
+  grub_ssize_t start, filelen;
27a4da
   void *kernel = NULL;
27a4da
   int setup_header_end_offset;
27a4da
   int rc;
27a4da
@@ -212,18 +212,19 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
27a4da
       goto fail;
27a4da
     }
27a4da
 
27a4da
-  grub_dprintf ("linuxefi", "params = %p\n", (unsigned long) params);
27a4da
+  grub_dprintf ("linuxefi", "params = %p\n", params);
27a4da
 
27a4da
   grub_memset (params, 0, sizeof(*params));
27a4da
 
27a4da
   setup_header_end_offset = *((grub_uint8_t *)kernel + 0x201);
27a4da
-  grub_dprintf ("linuxefi", "copying %d bytes from %p to %p\n",
27a4da
-		MIN(0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1,
27a4da
+  grub_dprintf ("linuxefi", "copying %zu bytes from %p to %p\n",
27a4da
+		MIN((grub_size_t)0x202+setup_header_end_offset,
27a4da
+		    sizeof (*params)) - 0x1f1,
27a4da
 		(grub_uint8_t *)kernel + 0x1f1,
27a4da
 		(grub_uint8_t *)params + 0x1f1);
27a4da
   grub_memcpy ((grub_uint8_t *)params + 0x1f1,
27a4da
 	       (grub_uint8_t *)kernel + 0x1f1,
27a4da
-		MIN(0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1);
27a4da
+		MIN((grub_size_t)0x202+setup_header_end_offset,sizeof (*params)) - 0x1f1);
27a4da
   lh = (struct linux_kernel_header *)params;
27a4da
   grub_dprintf ("linuxefi", "lh is at %p\n", lh);
27a4da
   grub_dprintf ("linuxefi", "checking lh->boot_flag\n");
27a4da
@@ -254,7 +255,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
27a4da
       goto fail;
27a4da
     }
27a4da
 
27a4da
-#ifdef defined(__x86_64__) || defined(__aarch64__)
27a4da
+#if defined(__x86_64__) || defined(__aarch64__)
27a4da
   grub_dprintf ("linuxefi", "checking lh->xloadflags\n");
27a4da
   if (!(lh->xloadflags & LINUX_XLF_KERNEL_64))
27a4da
     {
27a4da
@@ -297,7 +298,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
27a4da
   handover_offset = lh->handover_offset;
27a4da
 
27a4da
   start = (lh->setup_sects + 1) * 512;
27a4da
-  len = grub_file_size(file) - start;
27a4da
 
27a4da
   kernel_mem = grub_efi_allocate_pages(lh->pref_address,
27a4da
 				       BYTES_TO_PAGES(lh->init_size));
27a4da
@@ -343,7 +343,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
27a4da
       loaded = 0;
27a4da
     }
27a4da
 
27a4da
-  if (linux_cmdline && !loaded)
27a4da
+  if (linux_cmdline && lh && !loaded)
27a4da
     grub_efi_free_pages ((grub_efi_physical_address_t)(grub_addr_t)
27a4da
 			 linux_cmdline,
27a4da
 			 BYTES_TO_PAGES(lh->cmdline_size + 1));
27a4da
-- 
27a4da
2.13.0
27a4da