From 107eb02d3f1b1d3949c8f04af7f861c2c7c4522c Mon Sep 17 00:00:00 2001 From: baiguo Date: Tue, 9 Apr 2024 11:15:40 +0800 Subject: [PATCH] fix potential segfault and leaking error in bd_lvm_init --- ...ult-and-leaking-error-in-bd_lvm_init.patch | 54 +++++++++++++++++++ libblockdev.spec | 6 ++- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 0009-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch diff --git a/0009-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch b/0009-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch new file mode 100644 index 0000000..46ea353 --- /dev/null +++ b/0009-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch @@ -0,0 +1,54 @@ +From 78fbf368e2731cbe8b13859599a63bf6b6ea8f57 Mon Sep 17 00:00:00 2001 +From: vtrefny vtrefny@redhat.com +Date: Tue, 9 Apr 2024 11:10:31 +0800 +Subject: [PATCH] fix potential segfault and leaking error in-bd_lvm_init + +--- + src/plugins/lvm-dbus.c | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c +index dfa12ff..2c0c105 100644 +--- a/src/plugins/lvm-dbus.c ++++ b/src/plugins/lvm-dbus.c +@@ -221,7 +221,7 @@ static gboolean setup_dbus_connection (GError **error) { + + addr = g_dbus_address_get_for_bus_sync (G_BUS_TYPE_SYSTEM, NULL, error); + if (!addr) { +- g_critical ("Failed to get system bus address: %s\n", (*error)->message); ++ g_prefix_error (error, "Failed to get system bus address: "); + return FALSE; + } + +@@ -231,12 +231,18 @@ static gboolean setup_dbus_connection (GError **error) { + NULL, NULL, error); + + g_free (addr); ++ if (!bus) { ++ g_prefix_error (error, "Failed to create a new connection for the system bus: "); ++ return FALSE; ++ } + +- if (!bus || g_dbus_connection_is_closed (bus)) { +- g_critical ("Failed to create a new connection for the system bus: %s\n", (*error)->message); ++ if (g_dbus_connection_is_closed (bus)) { ++ g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_FAIL, ++ "Connection is closed"); + return FALSE; + } + ++ + g_dbus_connection_set_exit_on_close (bus, FALSE); + + return TRUE; +@@ -320,6 +326,7 @@ gboolean bd_lvm_init (void) { + completely rely on it */ + if (G_UNLIKELY(!bus) && !setup_dbus_connection (&error)) { + g_critical ("Failed to setup DBus connection: %s", error->message); ++ g_clear_error (&error); + return FALSE; + } + +-- +2.27.0 + diff --git a/libblockdev.spec b/libblockdev.spec index ae98eb2..924d3c2 100644 --- a/libblockdev.spec +++ b/libblockdev.spec @@ -3,7 +3,7 @@ Name: libblockdev Version: 2.26 -Release: 4 +Release: 5 Summary: libblockdev is a C library supporting GObject introspection for manipulation of block devices License: LGPLv2+ URL: https://github.com/storaged-project/libblockdev @@ -17,6 +17,7 @@ Patch5: 0005-lvm-Fix-memory-leak-bd_lvm_cache_create_cached_lv.patch Patch6: 0006-fs-Fix-return-values-in-bd_fs_ntfs_get_info.patch Patch7: 0007-fs-Fix-return-values-in-bd_fs_xfs_get_info.patch Patch8: 0008-dm-Fix-comparing-DM-RAID-member-devices-UUID.patch +Patch9: 0009-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch BuildRequires: make glib2-devel libyaml-devel libbytesize-devel parted-devel libuuid-devel ndctl-devel device-mapper-devel BuildRequires: device-mapper-devel systemd-devel nss-devel volume_key-devel >= 0.3.9-7 libblkid-devel libmount-devel @@ -166,6 +167,9 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm} %changelog +* Tue Apr 9 2024 baiguo - 2.26-5 +- fix potential segfault and leaking error in bd_lvm_init + * Tue Jan 2 2024 liyanan - 2.26-4 - remove require vdo -- Gitee