[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] chainloader: Fix wrong break condition (must be AND not OR)

From: C. Masloch
Subject: [PATCH] chainloader: Fix wrong break condition (must be AND not OR)
Date: Sun, 21 Jan 2018 16:02:10 +0100

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 +
 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
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)
-      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)

       if (bpb->num_fats == 0)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]