From: Andrey Borzenkov <arvidjaar@gmail.com>
Subject: [PATCH] fix off by one error in enumerating MSDOS partitions
References: bnc#779534

As reported in https://bugzilla.novell.com/show_bug.cgi?id=779534,
grub2 assigns incorrect partition number to extended partitions.
This is due to slightly non-standard EBR which contains single extended
partition record, but no normal partition. Due to incorrect p.number
comparison, grub2 includes it in partition numbering.

With standard EBR first entry is "true" partition that correctly
gets assigned next available number.

At the point of comparison p.number is one less than partition
number; so make correct comparison.

Actual partition chain is visible in this attachement:
http://bugzilla.novell.com/attachment.cgi?id=519076

Signed-off-by: Andrey Borzenkov <arvidjaar@gmail.com>

---
 ChangeLog                 |    5 +++++
 grub-core/partmap/msdos.c |    2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 75fb85a..1da1c31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-01-07  Andrey Borzenkov <arvidjaar@gmail.com>
+
+	* grub-core/partmap/msdos.c (grub_partition_msdos_iterate):
+	Fix off by one error in enumerating extended partitions.
+
 2013-01-07  Colin Watson  <cjwatson@ubuntu.com>
 
 	* grub-core/io/bufio.c (grub_bufio_open): Use grub_zalloc instead of
diff --git a/grub-core/partmap/msdos.c b/grub-core/partmap/msdos.c
index 10ca3f0..6ddb071 100644
--- a/grub-core/partmap/msdos.c
+++ b/grub-core/partmap/msdos.c
@@ -189,7 +189,7 @@ grub_partition_msdos_iterate (grub_disk_t disk,
 	      if (hook (disk, &p))
 		return grub_errno;
 	    }
-	  else if (p.number < 4)
+	  else if (p.number < 3)
 	    /* If this partition is a logical one, shouldn't increase the
 	       partition number.  */
 	    p.number++;
-- 
tg: (d15e99a..) u/empty-msdos-partition (depends on: master)
