udisks2: Correct add to hash table for items which can clash in the monitor

Related: RHEL-76484
This commit is contained in:
Milan Crha 2026-02-06 07:33:07 +01:00
parent 88981dbf75
commit c64ab34ccb
2 changed files with 42 additions and 1 deletions

View File

@ -25,7 +25,7 @@
Name: gvfs
Version: 1.36.2
Release: 19%{?dist}
Release: 20%{?dist}
Summary: Backends for the gio framework in GLib
License: GPLv3 and LGPLv2+ and BSD and MPLv2.0
@ -97,6 +97,7 @@ Patch26: udisks2-monitor-performance-202.patch
Patch27: udisks2-monitor-performance-230.patch
Patch28: udisks2-monitor-performance-273.patch
Patch29: udisks2-monitor-performance-290.patch
Patch30: udisks2-monitor-performance-297.patch
BuildRequires: pkgconfig
BuildRequires: pkgconfig(glib-2.0) >= %{glib2_version}
@ -488,6 +489,9 @@ killall -USR1 gvfsd >&/dev/null || :
%{_datadir}/installed-tests
%changelog
* Fri Feb 06 2026 Milan Crha <mcrha@redhat.com> - 1.36.2-20
- udisks2: Correct add to hash table for items which can clash in the monitor (RHEL-76484)
* Wed Jan 21 2026 Milan Crha <mcrha@redhat.com> - 1.36.2-19
- udisks2: Use hash table for quicker lookups in the monitor (RHEL-76484)

View File

@ -0,0 +1,37 @@
From 3e3691a59b69aeafac4288e0599fca3eb4cb02f3 Mon Sep 17 00:00:00 2001
Date: Tue, 3 Feb 2026 19:15:32 +0100
Subject: [PATCH] udisks2: Fix memory corruption with duplicate mount paths
Calling g_hash_table_insert on a key that already exists in the table frees
the old value and the *new* key, thus leaving the old key pointing to free'd
memory. g_hash_table_replace instead frees the old value and key together
and inserts the new value and key into the table.
---
monitor/udisks2/gvfsudisks2volumemonitor.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.c b/monitor/udisks2/gvfsudisks2volumemonitor.c
index c57249e5..aa1ca7a3 100644
--- a/monitor/udisks2/gvfsudisks2volumemonitor.c
+++ b/monitor/udisks2/gvfsudisks2volumemonitor.c
@@ -730,7 +730,7 @@ update_all (GVfsUDisks2VolumeMonitor *monitor,
for (link = entries; link != NULL; link = g_list_next (link))
{
GUnixMountEntry *mount_entry = link->data;
- g_hash_table_insert (mount_entries, (gpointer) g_unix_mount_get_mount_path (mount_entry), mount_entry);
+ g_hash_table_replace (mount_entries, (gpointer) g_unix_mount_get_mount_path (mount_entry), mount_entry);
}
/* the mount_entries took ownership of the mount entry objects */
g_list_free (entries);
@@ -742,7 +742,7 @@ update_all (GVfsUDisks2VolumeMonitor *monitor,
for (link = points; link != NULL; link = g_list_next (link))
{
GUnixMountPoint *mount_point = link->data;
- g_hash_table_insert (mount_points_by_path, (gpointer) g_unix_mount_point_get_mount_path (mount_point), mount_point);
+ g_hash_table_replace (mount_points_by_path, (gpointer) g_unix_mount_point_get_mount_path (mount_point), mount_point);
}
/* the mount_points_by_path took ownership of the mount point objects */
g_list_free (points);
--
GitLab