Skip to contentSkip to conversation

Issue in cvs kern/elf.c

PATCH Pattrick Hueper 2 participants 2 messages Apr 18, 2007

lore
Share & tools
lore
#0 lore raw

Hi all,

testing grub2 on a 64bit platform i found an issue in kern/elf.c method grub_elf64_load.

There are parentheses missing after the compare of read bytes and expected filesize causing the load to always fail with GRUB_ERR_BAD_OS.

Here is the cvs patch that fixed the issue for me:

Index: kern/elf.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/elf.c,v
retrieving revision 1.5

elf.c 18 Apr 2007 09:02:44 -0000 renamed from elf.c 20 Feb 2007 22:46:12 -0000 1.5 +0 -0
diff -u -r1.5 elf.c
@@ -432,12 +432,14 @@
       grub_ssize_t read;
       read = grub_file_read (elf->file, (void *) load_addr,
phdr->p_filesz);
       if (read != (grub_ssize_t) phdr->p_filesz)
-         /* XXX How can we free memory from `load_hook'?  */
-         grub_error_push ();
-         return grub_error (GRUB_ERR_BAD_OS,
-                            "Couldn't read segment from file: "
-                            "wanted 0x%lx bytes; read 0x%lx bytes.",
-                            phdr->p_filesz, read);
+          {
+           /* XXX How can we free memory from `load_hook'?  */
+           grub_error_push ();
+           return grub_error (GRUB_ERR_BAD_OS,
+                            "Couldn't read segment from file: "
+                            "wanted 0x%lx bytes; read 0x%lx bytes.",
+                            phdr->p_filesz, read);
+          }
      }

    if (phdr->p_filesz < phdr->p_memsz)

Best Regards, Pattrick

#1 lore raw

This is an obvious problem. Thanks for finding it Pattrick! I will commit the fix today.

Quoted 49 lines · Pattrick Hueper

Hi all,

testing grub2 on a 64bit platform i found an issue in kern/elf.c method grub_elf64_load.

There are parentheses missing after the compare of read bytes and expected filesize causing the load to always fail with GRUB_ERR_BAD_OS.

Here is the cvs patch that fixed the issue for me:

Index: kern/elf.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/elf.c,v
retrieving revision 1.5
diff -u -r1.5 elf.c

elf.c 18 Apr 2007 09:02:44 -0000 renamed from elf.c 20 Feb 2007 22:46:12 -0000 1.5 +8 -6
@@ -432,12 +432,14 @@
        grub_ssize_t read;
        read = grub_file_read (elf->file, (void *) load_addr,
 phdr->p_filesz);
        if (read != (grub_ssize_t) phdr->p_filesz)
-         /* XXX How can we free memory from `load_hook'?  */
-         grub_error_push ();
-         return grub_error (GRUB_ERR_BAD_OS,
-                            "Couldn't read segment from file: "
-                            "wanted 0x%lx bytes; read 0x%lx bytes.",
-                            phdr->p_filesz, read);
+          {
+           /* XXX How can we free memory from `load_hook'?  */
+           grub_error_push ();
+           return grub_error (GRUB_ERR_BAD_OS,
+                            "Couldn't read segment from file: "
+                            "wanted 0x%lx bytes; read 0x%lx bytes.",
+                            phdr->p_filesz, read);
+          }
       }
 
     if (phdr->p_filesz < phdr->p_memsz)

Best Regards, Pattrick

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel