From 1ca859a3e8d0cbad8e0331f44746618c22f5c48d Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 4 Sep 2012 16:59:04 -0700 Subject: [PATCH] - reallocate buf after _disk_analyse_block_size (#835601) --- ...cate-buf-after-_disk_analyse_block_s.patch | 36 +++++++++++++++++++ parted.spec | 6 +++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 parted-3.1-libparted-reallocate-buf-after-_disk_analyse_block_s.patch diff --git a/parted-3.1-libparted-reallocate-buf-after-_disk_analyse_block_s.patch b/parted-3.1-libparted-reallocate-buf-after-_disk_analyse_block_s.patch new file mode 100644 index 0000000..48f66bc --- /dev/null +++ b/parted-3.1-libparted-reallocate-buf-after-_disk_analyse_block_s.patch @@ -0,0 +1,36 @@ +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 + diff --git a/parted.spec b/parted.spec index a9cb6b2..77645af 100644 --- a/parted.spec +++ b/parted.spec @@ -4,7 +4,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.1 -Release: 6%{?dist} +Release: 7%{?dist} License: GPLv3+ Group: Applications/System URL: http://www.gnu.org/software/parted @@ -22,6 +22,7 @@ Patch5: parted-3.1-libparted-use-largest_partnum-in-dm_reread_part_tabl.patch patch6: parted-3.1-test-creating-20-device-mapper-partitions.patch Patch7: parted-3.1-libparted-preserve-the-uuid-on-dm-partitions.patch Patch8: parted-3.1-tests-Make-sure-dm-UUIDs-are-not-erased.patch +Patch9: parted-3.1-libparted-reallocate-buf-after-_disk_analyse_block_s.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: e2fsprogs-devel @@ -157,6 +158,9 @@ fi %changelog +* Tue Sep 04 2012 Brian C. Lane 3.1-7 +- reallocate buf after _disk_analyse_block_size (#835601) + * Fri Aug 03 2012 Brian C. Lane 3.1-6 - Use dm_udev_wait for dm operations (#844257) (bcl) - use largest_partnum in _dm_reread_part_table (bcl)