- reallocate buf after _disk_analyse_block_size (#835601)

This commit is contained in:
Brian C. Lane 2012-09-04 16:59:04 -07:00
parent 5c7b01233e
commit 1ca859a3e8
2 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,36 @@
From 4ee2a7d03f6720c5f97eef93c4df4b9c52e79b5e Mon Sep 17 00:00:00 2001
From: Brian C. Lane <bcl@redhat.com>
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

View File

@ -4,7 +4,7 @@
Summary: The GNU disk partition manipulation program Summary: The GNU disk partition manipulation program
Name: parted Name: parted
Version: 3.1 Version: 3.1
Release: 6%{?dist} Release: 7%{?dist}
License: GPLv3+ License: GPLv3+
Group: Applications/System Group: Applications/System
URL: http://www.gnu.org/software/parted 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 patch6: parted-3.1-test-creating-20-device-mapper-partitions.patch
Patch7: parted-3.1-libparted-preserve-the-uuid-on-dm-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 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) Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: e2fsprogs-devel BuildRequires: e2fsprogs-devel
@ -157,6 +158,9 @@ fi
%changelog %changelog
* Tue Sep 04 2012 Brian C. Lane <bcl@redhat.com> 3.1-7
- reallocate buf after _disk_analyse_block_size (#835601)
* Fri Aug 03 2012 Brian C. Lane <bcl@redhat.com> 3.1-6 * Fri Aug 03 2012 Brian C. Lane <bcl@redhat.com> 3.1-6
- Use dm_udev_wait for dm operations (#844257) (bcl) - Use dm_udev_wait for dm operations (#844257) (bcl)
- use largest_partnum in _dm_reread_part_table (bcl) - use largest_partnum in _dm_reread_part_table (bcl)