diff --git a/0002-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch b/0002-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch new file mode 100644 index 0000000000000000000000000000000000000000..2d0900c3e90c9bf582b61cdede1c47c9b14ff968 --- /dev/null +++ b/0002-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch @@ -0,0 +1,50 @@ +From 72a65429ce31a2b66eaa1140e029ff8de89c0275 Mon Sep 17 00:00:00 2001 +From: vtrefny vtrefny@redhat.com +Date: Tue, 2 Apr 2024 13:56:27 +0800 +Subject: [PATCH] Fix potential segfault in bd_lvm_init + +--- + src/plugins/lvm-dbus.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c +index e822bd6..8042945 100644 +--- a/src/plugins/lvm-dbus.c ++++ b/src/plugins/lvm-dbus.c +@@ -257,7 +257,7 @@ static gboolean setup_dbus_connection (GError **error) { + + addr = g_dbus_address_get_for_bus_sync (G_BUS_TYPE_SYSTEM, NULL, error); + if (!addr) { +- bd_utils_log_format (BD_UTILS_LOG_CRIT, "Failed to get system bus address: %s\n", (*error)->message); ++ g_prefix_error (error, "Failed to get system bus address: "); + return FALSE; + } + +@@ -267,9 +267,14 @@ 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)) { +- bd_utils_log_format (BD_UTILS_LOG_CRIT, "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; + } + +@@ -337,6 +342,7 @@ gboolean bd_lvm_init (void) { + completely rely on it */ + if (G_UNLIKELY (!bus) && !setup_dbus_connection (&error)) { + bd_utils_log_format (BD_UTILS_LOG_CRIT, "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 0aa6de321b30001b6bdfeffe021e194b5f8879da..2eb1fc139d2a4b121005cae34c8697f91049f3f4 100644 --- a/libblockdev.spec +++ b/libblockdev.spec @@ -3,13 +3,14 @@ Name: libblockdev Version: 3.0.4 -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 Source0: https://github.com/storaged-project/libblockdev/releases/download/%{version}-1/%{name}-%{version}.tar.gz Patch1: 0001-Add-BDPluginSpec-constructor-and-use-it-in-plugin_sp.patch +Patch2: 0002-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 @@ -159,6 +160,12 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm} %changelog +* Sun Apr 7 2024 baiguo - 3.0.4-5 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC: fix potential segfault and leaking error in bd_lvm_init + * Wed Apr 3 2024 wangzhiqiang - 3.0.4-4 - Type:bugfix - ID:NA