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

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