From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LUIXr-0000ob-7B for qemu-devel@nongnu.org; Tue, 03 Feb 2009 05:30:19 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LUIXo-0000oL-NM for qemu-devel@nongnu.org; Tue, 03 Feb 2009 05:30:18 -0500 Received: from [199.232.76.173] (port=58970 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUIXo-0000oE-H6 for qemu-devel@nongnu.org; Tue, 03 Feb 2009 05:30:16 -0500 Received: from mx1.redhat.com ([66.187.233.31]:43088) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LUIXo-0002SY-36 for qemu-devel@nongnu.org; Tue, 03 Feb 2009 05:30:16 -0500 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n13AUF90016740 for ; Tue, 3 Feb 2009 05:30:15 -0500 Received: from file.fab.redhat.com (file.fab.redhat.com [10.33.63.6]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n13AUGIq031073 for ; Tue, 3 Feb 2009 05:30:16 -0500 Received: from file.fab.redhat.com (localhost.localdomain [127.0.0.1]) by file.fab.redhat.com (8.13.1/8.13.1) with ESMTP id n13AUEis029988 for ; Tue, 3 Feb 2009 10:30:14 GMT Received: (from berrange@localhost) by file.fab.redhat.com (8.13.1/8.13.1/Submit) id n13AUD8c029984 for qemu-devel@nongnu.org; Tue, 3 Feb 2009 10:30:13 GMT Date: Tue, 3 Feb 2009 10:30:13 +0000 From: "Daniel P. Berrange" Subject: Re: [Qemu-devel] [PATCH] fix loading tiny kernels Message-ID: <20090203103013.GC8886@redhat.com> References: <49880773.5000203@exactcode.de> <49880902.20700@exactcode.de> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <49880902.20700@exactcode.de> Content-Transfer-Encoding: quoted-printable Reply-To: "Daniel P. Berrange" , qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Tue, Feb 03, 2009 at 10:06:10AM +0100, Ren? Rebe wrote: > I babbled: > >Further testing / polishing the multi-boot kernel loading support I fo= und > >the existing code fails to load unusual small kernels, less than 8192=20 > >bytes - > >for example the example multi-boot kernel shipped within GRUB that > >compiles to just 7121 bytes on my system. > > > >Signed-off-by: Ren=E9 Rebe > > > >--- hw/pc.c (revision 6501) > >+++ hw/pc.c (working copy) > >@@ -554,7 +989,7 @@ > > /* load the kernel header */ > > f =3D fopen(kernel_filename, "rb"); > > if (!f || !(kernel_size =3D get_file_size(f)) || > >- fread(header, 1, 1024, f) !=3D 1024) { > >+ fread(header, 1, MIN(8192, kernel_size), f) !=3D MIN(8192,=20 > >kernel_size)) { > > fprintf(stderr, "qemu: could not load kernel '%s'\n", > > kernel_filename); > > exit(1); > > > Ah, sorry - mix in the series. This only applies to the multi-boot ser= ies > which increases the header read to 8192 bytes. Regardless, this code should not hardcode the size like this. It should use sizeof(header) instead of 1024 or 8192, thus avoiding the potential bug. Regards, Daniel --=20 |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange= / :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.or= g :| |: http://autobuild.org -o- http://search.cpan.org/~danberr= / :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 950= 5 :|