From 6c184525320f8d40578e35e15d4965f1497d35f3 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 19 Sep 2012 02:48:29 +0100 Subject: [PATCH] Revert incorrect off-by-one fix when embedding in MBR (LP: #1051154). --- debian/changelog | 1 + debian/patches/msdos_embed_off_by_one.patch | 30 +++++++++++++++++++++ debian/patches/series | 1 + grub-core/partmap/msdos.c | 4 +-- 4 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 debian/patches/msdos_embed_off_by_one.patch diff --git a/debian/changelog b/debian/changelog index 3f31c3061..d979b02a2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ grub2 (2.00-5) UNRELEASED; urgency=low * Backport from upstream: - Remove extra layer of escaping from grub_probe. - Add efifwsetup module to reboot into firmware setup menu. + - Revert incorrect off-by-one fix when embedding in MBR (LP: #1051154). * Switch watch file to point to ftp.gnu.org. * Build-depend on liblzma-dev, enabling 'grub-mkimage -C xz'. * Adjust /etc/grub.d/30_os-prober to detect Ubuntu's use of "recovery" diff --git a/debian/patches/msdos_embed_off_by_one.patch b/debian/patches/msdos_embed_off_by_one.patch new file mode 100644 index 000000000..1ccdb5f66 --- /dev/null +++ b/debian/patches/msdos_embed_off_by_one.patch @@ -0,0 +1,30 @@ +Description: Revert incorrect off-by-one fix when embedding in MBR + A 62-sector core image should fit before end == 63. +Author: Colin Watson +Origin: upstream, http://bazaar.launchpad.net/~vcs-imports/grub/grub2-bzr/revision/4586 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1051154 +Forwarded: not-needed +Applied-Upstream: http://bazaar.launchpad.net/~vcs-imports/grub/grub2-bzr/revision/4586 +Last-Update: 2012-09-19 + +Index: b/grub-core/partmap/msdos.c +=================================================================== +--- a/grub-core/partmap/msdos.c ++++ b/grub-core/partmap/msdos.c +@@ -316,14 +316,14 @@ + break; + } + +- if (end >= *nsectors + 2) ++ if (end >= *nsectors + 1) + { + unsigned i, j; + char *embed_signature_check; + unsigned int orig_nsectors, avail_nsectors; + + orig_nsectors = *nsectors; +- *nsectors = end - 2; ++ *nsectors = end - 1; + avail_nsectors = *nsectors; + if (*nsectors > max_nsectors) + *nsectors = max_nsectors; diff --git a/debian/patches/series b/debian/patches/series index ff94c4561..929cc90d6 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -21,3 +21,4 @@ install_efi_fallback.patch mkconfig_overescaping.patch efifwsetup.patch mkconfig_ubuntu_recovery.patch +msdos_embed_off_by_one.patch diff --git a/grub-core/partmap/msdos.c b/grub-core/partmap/msdos.c index 6e54a7427..10ca3f08b 100644 --- a/grub-core/partmap/msdos.c +++ b/grub-core/partmap/msdos.c @@ -316,14 +316,14 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors, break; } - if (end >= *nsectors + 2) + if (end >= *nsectors + 1) { unsigned i, j; char *embed_signature_check; unsigned int orig_nsectors, avail_nsectors; orig_nsectors = *nsectors; - *nsectors = end - 2; + *nsectors = end - 1; avail_nsectors = *nsectors; if (*nsectors > max_nsectors) *nsectors = max_nsectors;