From 4ee2a7d03f6720c5f97eef93c4df4b9c52e79b5e Mon Sep 17 00:00:00 2001 From: Brian C. Lane Date: Tue, 4 Sep 2012 15:56:47 -0700 Subject: [PATCH] libparted: reallocate buf after _disk_analyse_block_size call 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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libparted/labels/mac.c b/libparted/labels/mac.c index 1f59a1a..5fa8283 100644 --- a/libparted/labels/mac.c +++ b/libparted/labels/mac.c @@ -759,6 +759,13 @@ 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); + if (!buf) + goto error; + 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