The call to _disk_analyse_block_size may change the
disk->dev->sector_size, if this happens buf may be too small for
subsequent reads.

libparted/labels/mac.c (mac_read): reallocate buf
---
 libparted/labels/mac.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c
index 1f59a1a..e058124 100644
--- a/libparted/labels/mac.c
+++ b/libparted/labels/mac.c
@@ -759,6 +759,11 @@ mac_read (PedDisk* disk)
                mac_disk_data->block_size = raw_disk->block_size;
        }
 
+       /* re-allocate buf in case _disk_analyse_block_size changed
+       * the sector_size */
+       free (buf);
+       buf = ped_malloc (disk->dev->sector_size);
+
        for (num=1; num==1 || num <= last_part_entry_num; num++) {
                void *raw_part = buf;
                if (!ped_device_read (disk->dev, raw_part,
-- 
1.7.11.4


Reply via email to