[syslinux] [PATCH 2/2] chain.c32: fix test for partition types which can be hidden

Sergey Vlasov vsu at altlinux.ru
Wed Jul 16 04:13:21 PDT 2008


The result of shift in C is undefined if the shift count is greater
than the width of type.  On x86 the corresponding CPU instruction
masks the shift count with 0x1f, therefore (mask >> (t & ~0x10)) & 1)
gives false positives for types greater than 0x1f (e.g., the partition
type 0x8e (Linux LVM) could be "hidden" to 0x9e).

Signed-off-by: Sergey Vlasov <vsu at altlinux.ru>
---
 com32/modules/chain.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/com32/modules/chain.c b/com32/modules/chain.c
index 9ca118c..2f79aaf 100644
--- a/com32/modules/chain.c
+++ b/com32/modules/chain.c
@@ -626,7 +626,7 @@ static int hide_unhide(char *mbr, int part)
   for (i = 1; i <= 4; i++) {
     pt = (struct part_entry *)&mbr[0x1be + 16*(i-1)];
     t = pt->ostype;
-    if ((mask >> (t & ~0x10)) & 1) {
+    if ((t <= 0x1f) && ((mask >> (t & ~0x10)) & 1)) {
       /* It's a hideable partition type */
       if (i == part)
 	t &= ~0x10;	/* unhide */
-- 
1.5.6.2.305.g2938b




More information about the Syslinux mailing list