]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/partmap/gpt.c (grub_gpt_partition_map_iterate): Accept
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 22 May 2012 07:09:00 +0000 (09:09 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 22 May 2012 07:09:00 +0000 (09:09 +0200)
protective entry in any slot.
* grub-core/partmap/msdos.c (grub_partition_msdos_iterate): Reject
if protective entry is found in any slot.

Protective entry in non-first slot make no sense but is a widespread
brain damage.

ChangeLog
grub-core/partmap/gpt.c
grub-core/partmap/msdos.c

index b064e6c310f4f5e83ae25a84b2002b61f267ee1d..9c734d9c2bf2564c1c5eeea98c7308821b1686fe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-05-22  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/partmap/gpt.c (grub_gpt_partition_map_iterate): Accept
+       protective entry in any slot.
+       * grub-core/partmap/msdos.c (grub_partition_msdos_iterate): Reject
+       if protective entry is found in any slot.
+
+       Protective entry in non-first slot make no sense but is a widespread
+       brain damage.
+
 2012-05-22  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/fs/squash4.c (grub_squash_read_data): Add missing byte-swap.
index c51753d5fb415c6d758a083e7d2a4006ee099b9c..17f242d1d516564b5edbd48147d2cae3fb320c7d 100644 (file)
@@ -69,7 +69,10 @@ grub_gpt_partition_map_iterate (grub_disk_t disk,
     return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature");
 
   /* Make sure the MBR is a protective MBR and not a normal MBR.  */
-  if (mbr.entries[0].type != GRUB_PC_PARTITION_TYPE_GPT_DISK)
+  for (i = 0; i < 4; i++)
+    if (mbr.entries[i].type == GRUB_PC_PARTITION_TYPE_GPT_DISK)
+      break;
+  if (i == 4)
     return grub_error (GRUB_ERR_BAD_PART_TABLE, "no GPT partition map found");
 
   /* Read the GPT header.  */
index 60caa9ec88c65d9378303555f117c0df2eef6976..6e54a7427176bb00ac997d9ac17eed4ad339f453 100644 (file)
@@ -136,6 +136,12 @@ grub_partition_msdos_iterate (grub_disk_t disk,
       if (grub_disk_read (disk, p.offset, 0, sizeof (mbr), &mbr))
        goto finish;
 
+      /* If this is a GPT partition, this MBR is just a dummy.  */
+      if (p.offset == 0)
+       for (i = 0; i < 4; i++)
+         if (mbr.entries[i].type == GRUB_PC_PARTITION_TYPE_GPT_DISK)
+           return grub_error (GRUB_ERR_BAD_PART_TABLE, "dummy mbr");
+
       /* This is our loop-detection algorithm. It works the following way:
         It saves last position which was a power of two. Then it compares the
         saved value with a current one. This way it's guaranteed that the loop
@@ -174,10 +180,6 @@ grub_partition_msdos_iterate (grub_disk_t disk,
                        (unsigned long long) p.start,
                        (unsigned long long) p.len);
 
-         /* If this is a GPT partition, this MBR is just a dummy.  */
-         if (e->type == GRUB_PC_PARTITION_TYPE_GPT_DISK && p.index == 0)
-           return grub_error (GRUB_ERR_BAD_PART_TABLE, "dummy mbr");
-
          /* If this partition is a normal one, call the hook.  */
          if (! grub_msdos_partition_is_empty (e->type)
              && ! grub_msdos_partition_is_extended (e->type))