Received: from list by lists.gnu.org with archive (Exim 4.71) id 1edH8b-0001fF-77 for mharc-grub-devel@gnu.org; Sun, 21 Jan 2018 10:02:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edH8U-0001e5-EV for grub-devel@gnu.org; Sun, 21 Jan 2018 10:02:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1edH8R-0003Yv-SE for grub-devel@gnu.org; Sun, 21 Jan 2018 10:02:18 -0500 Received: from mail.38.de ([81.209.249.38]:41540) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1edH8R-0003Xx-J3 for grub-devel@gnu.org; Sun, 21 Jan 2018 10:02:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=38.de; s=mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Date:Message-ID:Subject:From:To; bh=vPbgTdLUEnWizf9/k30yNrOWslPmkPu14+qCu5r9sFE=; b=XLrqRLneYCiwMIdR31t0NeYrOp7U+slKfz1RDj4NoNm9DkJhoAzhMw+bhGyy+Dm5kWyu1u+cyKplVaTMOerfPYjoOvCdQ0ZLN07eo7/EfOTG2H7vO2FDT3ISOVOV1r4QaRtrvKi+u5pRyiwyM2J1xWshTyp2CDjSPFkXLpaNdEw=; Received: from x59cc990d.dyn.telefonica.de ([89.204.153.13] helo=[192.168.1.3]) by mail.38.de with esmtpsa (TLSv1:DHE-RSA-AES128-SHA:128) (Exim 4.80.1) (envelope-from ) id 1edH8O-0002rw-Fd for grub-devel@gnu.org; Sun, 21 Jan 2018 16:02:12 +0100 To: grub-devel@gnu.org From: "C. Masloch" Subject: [PATCH] chainloader: Fix wrong break condition (must be AND not OR) Message-ID: <1b69cd91-2263-e834-dbba-0af3de3ff0be@38.de> Date: Sun, 21 Jan 2018 16:02:10 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 81.209.249.38 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Jan 2018 15:02:19 -0000 The definition of bpb's num_total_sectors_16 and num_total_sectors_32 is that either the 16-bit field is non-zero and is used (in which case eg mkfs.fat sets the 32-bit field to zero), or it is zero and the 32-bit field is used. Therefore, a BPB is invalid only if *both* fields are zero; having one field as zero and the other as non-zero is the case to be expected. This affects all users of grub_chainloader_patch_bpb which are in chainloader.c, freedos.c, and ntldr.c Tested with lDebug booted in qemu via grub2's FreeDOS direct loading support, refer to https://bitbucket.org/ecm/ldosboot + https://bitbucket.org/ecm/ldebug --- grub-core/loader/i386/pc/chainloader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/i386/pc/chainloader.c b/grub-core/loader/i386/pc/chainloader.c index c79c4fe0f..18220b7aa 100644 --- a/grub-core/loader/i386/pc/chainloader.c +++ b/grub-core/loader/i386/pc/chainloader.c @@ -117,7 +117,7 @@ grub_chainloader_patch_bpb (void *bs, grub_device_t dev, grub_uint8_t dl) if (bpb->num_reserved_sectors == 0) break; - if (bpb->num_total_sectors_16 == 0 || bpb->num_total_sectors_32 == 0) + if (bpb->num_total_sectors_16 == 0 && bpb->num_total_sectors_32 == 0) break; if (bpb->num_fats == 0) -- 2.11.0