Fix segfault when adding a partition too big for MSDOS

Resolves: rhbz#2185564
This commit is contained in:
Vojtech Trefny 2023-05-16 10:50:21 +02:00
parent 95db11f02e
commit f31a022ba0
2 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,32 @@
From 9c96e621e9abb0649118d2e1731a09b1fa139579 Mon Sep 17 00:00:00 2001
From: Vojtech Trefny <vtrefny@redhat.com>
Date: Wed, 19 Apr 2023 09:50:38 +0200
Subject: [PATCH] part: Fix segfault when adding a partition too big for MSDOS
Resolves: rhbz#2185564
---
src/plugins/part.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/plugins/part.c b/src/plugins/part.c
index 8b2285f5..28e20c28 100644
--- a/src/plugins/part.c
+++ b/src/plugins/part.c
@@ -841,6 +841,14 @@ static gboolean resize_part (PedPartition *part, PedDevice *dev, PedDisk *disk,
constr = ped_constraint_any (dev);
geom = ped_disk_get_max_partition_geometry (disk, part, constr);
+ if (!geom) {
+ set_parted_error (error, BD_PART_ERROR_FAIL);
+ g_prefix_error (error, "Failed to create geometry for partition on device '%s'", dev->path);
+ ped_constraint_destroy (constr);
+ finish_alignment_constraint (disk, orig_flag_state);
+ return FALSE;
+ }
+
if (!ped_geometry_set_start (geom, start)) {
set_parted_error (error, BD_PART_ERROR_FAIL);
g_prefix_error (error, "Failed to set partition start on device '%s'", dev->path);
--
2.40.1

View File

@ -129,7 +129,7 @@
Name: libblockdev
Version: 2.28
Release: 5%{?dist}
Release: 6%{?dist}
Summary: A library for low-level manipulation with block devices
License: LGPLv2+
URL: https://github.com/storaged-project/libblockdev
@ -142,6 +142,7 @@ Patch4: 0004-Fix-double-free-in-write_escrow_data_file.patch
Patch5: 0005-nvme-Fix-namespace-identifiers.patch
Patch6: 0006-Allow-resizing-of-inactive-LVs-with-latest-LVM.patch
Patch7: 0007-tests-Fix-test_swapon_pagesize-on-systems-with-64k-p.patch
Patch8: 0008-part-Fix-segfault-when-adding-a-partition-too-big-fo.patch
BuildRequires: make
BuildRequires: glib2-devel
@ -730,6 +731,7 @@ A meta-package that pulls all the libblockdev plugins as dependencies.
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%build
autoreconf -ivf
@ -1048,6 +1050,10 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm}
%files plugins-all
%changelog
* Tue May 16 2023 Vojtech Trefny <vtrefny@redhat.com> - 2.28-6
- Fix segfault when adding a partition too big for MSDOS
Resolves: rhbz#2185564
* Mon Apr 03 2023 Vojtech Trefny <vtrefny@redhat.com> - 2.28-5
- Allow resizing of inactive LVs with latest LVM
Resolves: rhbz#2161181