]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/loader/efi/chainloader.c (grub_chainloader_unload): Set
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 10 May 2011 07:14:41 +0000 (09:14 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 10 May 2011 07:14:41 +0000 (09:14 +0200)
file_path to 0 for surety.
(grub_chainloader_boot): Set exit_data to NULL.
Unset the loader once done.
(grub_cmd_chainloader): Fix confusing error message if file is empty.

ChangeLog
grub-core/loader/efi/chainloader.c

index 9baad1f9c2dc9ad8f642fa93d91413334a65d678..ed0bc71d6373c8839e5b5cfb172a136f1ba26f23 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-05-09  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/loader/efi/chainloader.c (grub_chainloader_unload): Set
+       file_path to 0 for surety.
+       (grub_chainloader_boot): Set exit_data to NULL.
+       Unset the loader once done.
+       (grub_cmd_chainloader): Fix confusing error message if file is empty.
+
 2011-05-09  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/term/at_keyboard.c (fetch_key): Make a printf on
index 869b64ced674dc20fa1fea85ffe6b37d02b78fb3..5dd5adab2dccde15d76abe35a3a7d63e643de3a3 100644 (file)
@@ -57,6 +57,7 @@ grub_chainloader_unload (void)
   grub_free (file_path);
   grub_free (cmdline);
   cmdline = 0;
+  file_path = 0;
 
   grub_dl_unref (my_mod);
   return GRUB_ERR_NONE;
@@ -68,7 +69,7 @@ grub_chainloader_boot (void)
   grub_efi_boot_services_t *b;
   grub_efi_status_t status;
   grub_efi_uintn_t exit_data_size;
-  grub_efi_char16_t *exit_data;
+  grub_efi_char16_t *exit_data = NULL;
 
   b = grub_efi_system_table->boot_services;
   status = efi_call_3 (b->start_image, image_handle, &exit_data_size, &exit_data);
@@ -95,7 +96,7 @@ grub_chainloader_boot (void)
   if (exit_data)
     efi_call_1 (b->free_pool, exit_data);
 
-  grub_chainloader_unload ();
+  grub_loader_unset ();
 
   return grub_errno;
 }
@@ -238,6 +239,11 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
   grub_efi_print_device_path (file_path);
 
   size = grub_file_size (file);
+  if (!size)
+    {
+      grub_error (GRUB_ERR_BAD_OS, "file is empty");
+      goto fail;
+    }
   pages = (((grub_efi_uintn_t) size + ((1 << 12) - 1)) >> 12);
 
   status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ANY_PAGES,