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

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