Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1HeD7V-00078w-Pk for mharc-grub-devel@gnu.org; Wed, 18 Apr 2007 12:35:01 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HeD7U-00076c-6S for grub-devel@gnu.org; Wed, 18 Apr 2007 12:35:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HeD7R-00072P-DW for grub-devel@gnu.org; Wed, 18 Apr 2007 12:34:59 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HeD7Q-000721-Uh for grub-devel@gnu.org; Wed, 18 Apr 2007 12:34:57 -0400 Received: from an-out-0708.google.com ([209.85.132.249]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HeD2Z-0008IP-GS for grub-devel@gnu.org; Wed, 18 Apr 2007 12:29:55 -0400 Received: by an-out-0708.google.com with SMTP id b8so239580ana for ; Wed, 18 Apr 2007 09:29:53 -0700 (PDT) Received: by 10.100.96.9 with SMTP id t9mr489078anb.1176913792954; Wed, 18 Apr 2007 09:29:52 -0700 (PDT) Received: by 10.100.137.6 with HTTP; Wed, 18 Apr 2007 09:29:52 -0700 (PDT) Message-ID: Date: Wed, 18 Apr 2007 18:29:52 +0200 From: "Pattrick Hueper" To: grub-devel@gnu.org MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_104217_32080485.1176913792909" X-detected-kernel: Linux 2.6 (newer, 2) Subject: Issue in cvs kern/elf.c X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Apr 2007 16:35:00 -0000 ------=_Part_104217_32080485.1176913792909 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 --- kern/elf.c 20 Feb 2007 22:46:12 -0000 1.5 +++ kern/elf.c 18 Apr 2007 09:02:44 -0000 @@ -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 ------=_Part_104217_32080485.1176913792909 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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
--- kern/elf.c  20 Feb 2007 22:46:12 -0000      1.5
+++ kern/elf.c  18 Apr 2007 09:02:44 -0000
@@ -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
------=_Part_104217_32080485.1176913792909--