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

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