Blame SOURCES/parted-3.1-libparted-reallocate-buf-after-_disk_analyse_block_s.patch

fc4a62
From 4ee2a7d03f6720c5f97eef93c4df4b9c52e79b5e Mon Sep 17 00:00:00 2001
fc4a62
From: Brian C. Lane <bcl@redhat.com>
fc4a62
Date: Tue, 4 Sep 2012 15:56:47 -0700
fc4a62
Subject: [PATCH] libparted: reallocate buf after _disk_analyse_block_size
fc4a62
 call
fc4a62
fc4a62
The call to _disk_analyse_block_size may change the
fc4a62
disk->dev->sector_size, if this happens buf may be too small for
fc4a62
subsequent reads.
fc4a62
fc4a62
libparted/labels/mac.c (mac_read): reallocate buf
fc4a62
---
fc4a62
 libparted/labels/mac.c | 7 +++++++
fc4a62
 1 file changed, 7 insertions(+)
fc4a62
fc4a62
diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c
fc4a62
index 1f59a1a..5fa8283 100644
fc4a62
--- a/libparted/labels/mac.c
fc4a62
+++ b/libparted/labels/mac.c
fc4a62
@@ -759,6 +759,13 @@ mac_read (PedDisk* disk)
fc4a62
 		mac_disk_data->block_size = raw_disk->block_size;
fc4a62
 	}
fc4a62
 
fc4a62
+	/* re-allocate buf in case _disk_analyse_block_size changed
fc4a62
+	* the sector_size */
fc4a62
+	free (buf);
fc4a62
+	buf = ped_malloc (disk->dev->sector_size);
fc4a62
+	if (!buf)
fc4a62
+		goto error;
fc4a62
+
fc4a62
 	for (num=1; num==1 || num <= last_part_entry_num; num++) {
fc4a62
 		void *raw_part = buf;
fc4a62
 		if (!ped_device_read (disk->dev, raw_part,
fc4a62
-- 
fc4a62
1.7.11.4
fc4a62