• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1From f43cf341511dd684a58c09e104e28c11987cbff1 Mon Sep 17 00:00:00 2001
2From: Rozhuk Ivan <rozhuk.im@gmail.com>
3Date: Sat, 25 Jun 2022 18:46:08 +0300
4Subject: [PATCH] [PATCH] Add lock in _g_get_unix_mount_points() around
5 *fsent() functions
6
7Conflict:NA
8Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/f43cf341511dd684a58c09e104e28c11987cbff1
9
10---
11 gio/gunixmounts.c | 22 +++++++++++++---------
12 1 file changed, 13 insertions(+), 9 deletions(-)
13
14diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c
15index 563bdba3b2..3005aa7af3 100644
16--- a/gio/gunixmounts.c
17+++ b/gio/gunixmounts.c
18@@ -1410,17 +1410,13 @@ _g_get_unix_mount_points (void)
19 {
20   struct fstab *fstab = NULL;
21   GUnixMountPoint *mount_point;
22-  GList *return_list;
23+  GList *return_list = NULL;
24+  G_LOCK_DEFINE_STATIC (fsent);
25 #ifdef HAVE_SYS_SYSCTL_H
26   int usermnt = 0;
27   struct stat sb;
28 #endif
29-
30-  if (!setfsent ())
31-    return NULL;
32
33-  return_list = NULL;
34-
35 #ifdef HAVE_SYS_SYSCTL_H
36 #if defined(HAVE_SYSCTLBYNAME)
37   {
38@@ -1448,7 +1444,14 @@ _g_get_unix_mount_points (void)
39   }
40 #endif
41 #endif
42-
43+
44+  G_LOCK (fsent);
45+  if (!setfsent ())
46+    {
47+      G_UNLOCK (fsent);
48+      return NULL;
49+    }
50+
51   while ((fstab = getfsent ()) != NULL)
52     {
53       gboolean is_read_only = FALSE;
54@@ -1482,9 +1485,10 @@ _g_get_unix_mount_points (void)
55
56       return_list = g_list_prepend (return_list, mount_point);
57     }
58-
59+
60   endfsent ();
61-
62+  G_UNLOCK (fsent);
63+
64   return g_list_reverse (return_list);
65 }
66 /* Interix {{{2 */
67--
68GitLab
69
70