Blob Blame History Raw
From 717affeb4dd8fb40d0b08e71a8a7cbaaabbf7e7e Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Sun, 26 Feb 2012 18:04:37 +0100
Subject: [PATCH] libparted: avoid unwarranted failed assertion during mklabel

This could happen when running "parted -s $dev mklabel $type" for
nearly any $type, assuming the underlying disk's sector size is
larger than 512 bytes.  This particular failure was noticed by
running tests/t9050-partition-table-types.sh with a simulated
sector size of 1024, as is done as part of a top-level "make check",
but so far, this failure has shown up only on RHEL-6.2.
That test attempts to exercise an ugly part of partition table
creation: during creation, parted checks for an existing
partition table by iterating through its list of known types and
attempting to read the disk, looking for a preexisting table.
Knowing this, the test takes all pairs of partition table types,
<A,B> and first creates a type of type A, and then creates on top
of that (erasing the original) a table of type B.
* libparted/labels/mac.c (_disk_analyse_ghost_size): Remove bogus
assertion.  If the number of the sector with a matching signature
is too large, simply reject it by returning 0.
* NEWS (Bug fixes): Mention this.
---
 NEWS                   |    5 +++++
 libparted/labels/mac.c |    3 +--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index d535612..2c1032d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,10 @@
 GNU parted NEWS                                    -*- outline -*-
 
+* Noteworthy changes in release 3.0-8 (Fedora)
+
+  libparted: creating a new partition table on a device with an existing
+  mac partition table could result in a failed assertion.
+
 * Noteworthy changes in release 3.0-6 (Fedora)
 
   Add the ability to set the boot flag on the GPT PMBR. This is needed
diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c
index bd756c2..3f04a51 100644
--- a/libparted/labels/mac.c
+++ b/libparted/labels/mac.c
@@ -704,8 +704,7 @@ _disk_analyse_ghost_size (PedDisk* disk)
 		if (_rawpart_check_signature (buf)
 		    && !_rawpart_is_void (buf)) {
 			mac_disk_data->ghost_size = i;
-			PED_ASSERT (i <= disk->dev->sector_size / 512);
-			found = 1;
+			found = (i <= disk->dev->sector_size / 512);
 			break;
 		}
 	}
-- 
1.7.7.6