]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2006-11-03 Hollis Blanchard <hollis@penguinppc.org>
authorhollisb <hollisb@localhost>
Fri, 3 Nov 2006 23:05:14 +0000 (23:05 +0000)
committerhollisb <hollisb@localhost>
Fri, 3 Nov 2006 23:05:14 +0000 (23:05 +0000)
* kern/elf.c (grub_elf_file): Call grub_file_seek. Call
grub_error_push and grub_error_pop in the error-handling path.
(grub_elf32_load_segment): Only call grub_file_read with non-zero
length.

ChangeLog
kern/elf.c

index 6ff44f6b0049b5a2698a34ae8afb9cf89759ca12..9c808c52c479fb431834b4b8cace02a39dc2dff6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-11-03  Hollis Blanchard  <hollis@penguinppc.org>
+
+       * kern/elf.c (grub_elf_file): Call grub_file_seek. Call
+       grub_error_push and grub_error_pop in the error-handling path.
+       (grub_elf32_load_segment): Only call grub_file_read with non-zero
+       length.
+
 2006-11-03  Hollis Blanchard  <hollis@penguinppc.org>
 
        * conf/i386-efi.rmk (grub_emu_SOURCES): Add kern/elf.c.
index 02619dd873ad234ae38ce18aa842b05bee8fbabe..df78dade4360c79c114743e66cb8801ea81dc6a1 100644 (file)
@@ -69,6 +69,9 @@ grub_elf_file (grub_file_t file)
   elf->file = file;
   elf->phdrs = 0;
 
+  if (grub_file_seek (elf->file, 0) == (grub_off_t) -1)
+    goto fail;
+
   if (grub_file_read (elf->file, (char *) &elf->ehdr, sizeof (elf->ehdr))
       != sizeof (elf->ehdr))
     {
@@ -82,7 +85,9 @@ grub_elf_file (grub_file_t file)
   return elf;
 
 fail:
+  grub_error_push ();
   grub_elf_close (elf);
+  grub_error_pop ();
   return 0;
 }
 
@@ -129,7 +134,8 @@ grub_elf32_load_segment (grub_elf_t elf, Elf32_Phdr *phdr, void *hook)
       return grub_error (GRUB_ERR_BAD_OS, "Invalid offset in program header");
     }
 
-  if (grub_file_read (elf->file, (void *) load_addr, phdr->p_filesz)
+  if (phdr->p_filesz
+      && grub_file_read (elf->file, (void *) load_addr, phdr->p_filesz)
       != (grub_ssize_t) phdr->p_filesz)
     {
       return grub_error (GRUB_ERR_BAD_OS, "Couldn't load segment");