diff --git a/0001-gmain-Add-a-missing-return-on-error-path-in-g_main_c.patch b/0001-gmain-Add-a-missing-return-on-error-path-in-g_main_c.patch new file mode 100644 index 0000000000000000000000000000000000000000..68afafee1c5bce99aabb92bc899b0bc39f742169 --- /dev/null +++ b/0001-gmain-Add-a-missing-return-on-error-path-in-g_main_c.patch @@ -0,0 +1,31 @@ +From c67dd9d3fe9186bef76ba682a7e277ccb7d95227 Mon Sep 17 00:00:00 2001 +From: Philip Withnall +Date: Tue, 18 Jul 2023 11:31:01 +0100 +Subject: [PATCH] gmain: Add a missing return on error path in + g_main_context_release() + +This should have been in commit +3926af723a7469a2ea492307f421820361d617b3. + +Signed-off-by: Philip Withnall + +Fixes: #3054 +--- + glib/gmain.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/glib/gmain.c b/glib/gmain.c +index fac14224a..ccadf76ce 100644 +--- a/glib/gmain.c ++++ b/glib/gmain.c +@@ -3608,6 +3608,7 @@ g_main_context_release (GMainContext *context) + g_critical ("g_main_context_release() called on a context (%p, owner %p, " + "owner count %u) which is not acquired by the current thread", + context, context_owner, context_owner_count); ++ return; + } + #endif /* !G_DISABLE_CHECKS */ + +-- +2.41.0 + diff --git a/backport-Align-G_FILE_MEASURE_APPARENT_SIZE-behaviour-with-du-from-GNU-coreutils.patch b/backport-Align-G_FILE_MEASURE_APPARENT_SIZE-behaviour-with-du-from-GNU-coreutils.patch deleted file mode 100644 index 9fd5fd01b74cfb2177a12a02b17856e5ee7e91bf..0000000000000000000000000000000000000000 --- a/backport-Align-G_FILE_MEASURE_APPARENT_SIZE-behaviour-with-du-from-GNU-coreutils.patch +++ /dev/null @@ -1,258 +0,0 @@ -From 011fe5ebb2516f0673819e6076d4d58d2618c2ea Mon Sep 17 00:00:00 2001 -From: Joan Bruguera -Date: Thu, 23 Mar 2023 02:24:30 +0000 -Subject: [PATCH 1/2] glocalfile: Sum apparent size only for files and symlinks - -Since GNU Coreutils 9.2 (commit 110bcd28386b1f47a4cd876098acb708fdcbbb25), -`du --apparent-size` (including `du --bytes`) no longer counts all kinds of -files (directories, FIFOs, etc.), but only those for which `st_size` in -`struct stat` is defined by POSIX, namely regular files and symlinks -(and also rarely supported memory objects). - -This aligns the behaviour of GLib's `G_FILE_MEASURE_APPARENT_SIZE` flag -with the new GNU Coreutils `du` and correct POSIX use. - -Note that this may be a breaking change for some uses. - -Link: https://lists.gnu.org/archive/html/bug-coreutils/2023-03/msg00007.html -Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2965 ---- - gio/gioenums.h | 3 +++ - gio/glocalfile.c | 37 +++++++++++++++++++++++++++++++++++++ - 2 files changed, 40 insertions(+) - -diff --git a/gio/gioenums.h b/gio/gioenums.h -index 7fd74a43ea..c820cd36d4 100644 ---- a/gio/gioenums.h -+++ b/gio/gioenums.h -@@ -224,6 +224,9 @@ typedef enum { - * sizes. Normally, the block-size is used, if available, as this is a - * more accurate representation of disk space used. - * Compare with `du --apparent-size`. -+ * Since GLib 2.78. and similarly to `du` since GNU Coreutils 9.2, this will -+ * ignore the sizes of file types other than regular files and links, as the -+ * sizes of other file types are not specified in a standard way. - * @G_FILE_MEASURE_NO_XDEV: Do not cross mount point boundaries. - * Compare with `du -x`. - * -diff --git a/gio/glocalfile.c b/gio/glocalfile.c -index 67d4b99fb7..dbb56902d5 100644 ---- a/gio/glocalfile.c -+++ b/gio/glocalfile.c -@@ -86,6 +86,9 @@ - #define FILE_READ_ONLY_VOLUME 0x00080000 - #endif - -+#ifndef S_ISREG -+#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) -+#endif - #ifndef S_ISDIR - #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) - #endif -@@ -2777,6 +2780,39 @@ g_local_file_measure_size_of_contents (gint fd, - MeasureState *state, - GError **error); - -+/* -+ * _g_stat_is_size_usable: -+ * @buf: a #GLocalFileStat. -+ * -+ * Checks if the file type is such that the `st_size` field of `struct stat` is -+ * well-defined by POSIX. -+ * (see https://pubs.opengroup.org/onlinepubs/009696799/basedefs/sys/stat.h.html) -+ * -+ * This behaviour is aligned with `du` from GNU Coreutils 9.2+ -+ * (see https://lists.gnu.org/archive/html/bug-coreutils/2023-03/msg00007.html) -+ * and makes apparent size sums well-defined; formerly, they depended on the -+ * implementation, and could differ across filesystems. -+ * -+ * Returns: %TRUE if the size field is well-defined, %FALSE otherwise. -+ **/ -+inline static gboolean -+_g_stat_is_size_usable (const GLocalFileStat *buf) -+{ -+#ifndef HAVE_STATX -+ /* Memory objects are defined by POSIX, but are not supported by statx nor Windows */ -+#ifdef S_TYPEISSHM -+ if (S_TYPEISSHM (buf)) -+ return TRUE; -+#endif -+#ifdef S_TYPEISTMO -+ if (S_TYPEISTMO (buf)) -+ return TRUE; -+#endif -+#endif -+ -+ return S_ISREG (_g_stat_mode (buf)) || S_ISLNK (_g_stat_mode (buf)); -+} -+ - static gboolean - g_local_file_measure_size_of_file (gint parent_fd, - GSList *name, -@@ -2836,6 +2872,7 @@ g_local_file_measure_size_of_file (gint parent_fd, - state->disk_usage += _g_stat_blocks (&buf) * G_GUINT64_CONSTANT (512); - else - #endif -+ if (_g_stat_is_size_usable (&buf)) - state->disk_usage += _g_stat_size (&buf); - - if (S_ISDIR (_g_stat_mode (&buf))) --- -GitLab - - -From d901b551288156e8dff2e6c7a4ecabbd76394710 Mon Sep 17 00:00:00 2001 -From: Joan Bruguera -Date: Thu, 23 Mar 2023 02:19:03 +0000 -Subject: [PATCH 2/2] tests/file: Do not rely on du --bytes behaviour - -As explained in the previous commit, GNU Coreutils 9.2 changes the behaviour -of `du --bytes` to only count regular files and symlinks. - -The previous commit makes the test pass with GNU Coreutils >=9.2, but the -machine running the tests may have an older version, or perhaps even a -reimplementation such as uutils. So we can't rely on the size returned by `du` -to be the consistent across systems any more. - -However, the plus side of the new behaviour is that the size reported by `du` -/ `G_FILE_MEASURE_APPARENT_SIZE` is now well-defined across filesystems -(as the sum of the sizes of regular files & symlinks), so we can hardcode it. - -Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/2965 ---- - gio/tests/file.c | 85 ++---------------------------------------------- - 1 file changed, 3 insertions(+), 82 deletions(-) - -diff --git a/gio/tests/file.c b/gio/tests/file.c -index d16eda5c0b..ad2f945f93 100644 ---- a/gio/tests/file.c -+++ b/gio/tests/file.c -@@ -2515,75 +2515,10 @@ test_copy_preserve_mode (void) - #endif - } - --static gchar * --splice_to_string (GInputStream *stream, -- GError **error) --{ -- GMemoryOutputStream *buffer = NULL; -- char *ret = NULL; -- -- buffer = (GMemoryOutputStream*)g_memory_output_stream_new (NULL, 0, g_realloc, g_free); -- if (g_output_stream_splice ((GOutputStream*)buffer, stream, 0, NULL, error) < 0) -- goto out; -- -- if (!g_output_stream_write ((GOutputStream*)buffer, "\0", 1, NULL, error)) -- goto out; -- -- if (!g_output_stream_close ((GOutputStream*)buffer, NULL, error)) -- goto out; -- -- ret = g_memory_output_stream_steal_data (buffer); -- out: -- g_clear_object (&buffer); -- return ret; --} -- --static gboolean --get_size_from_du (const gchar *path, guint64 *size) --{ -- GSubprocess *du; -- gboolean ok; -- gchar *result; -- gchar *endptr; -- GError *error = NULL; -- gchar *du_path = NULL; -- --#ifndef HAVE_COCOA -- du_path = g_find_program_in_path ("du"); --#endif -- -- /* If we can’t find du, don’t try and run the test. */ -- if (du_path == NULL) -- return FALSE; -- -- g_free (du_path); -- -- du = g_subprocess_new (G_SUBPROCESS_FLAGS_STDOUT_PIPE, -- &error, -- "du", "--bytes", "-s", path, NULL); -- g_assert_no_error (error); -- -- result = splice_to_string (g_subprocess_get_stdout_pipe (du), &error); -- g_assert_no_error (error); -- -- *size = g_ascii_strtoll (result, &endptr, 10); -- -- g_subprocess_wait (du, NULL, &error); -- g_assert_no_error (error); -- -- ok = g_subprocess_get_successful (du); -- -- g_object_unref (du); -- g_free (result); -- -- return ok; --} -- - static void - test_measure (void) - { - GFile *file; -- guint64 size; - guint64 num_bytes; - guint64 num_dirs; - guint64 num_files; -@@ -2594,12 +2529,6 @@ test_measure (void) - path = g_test_build_filename (G_TEST_DIST, "desktop-files", NULL); - file = g_file_new_for_path (path); - -- if (!get_size_from_du (path, &size)) -- { -- g_test_message ("du not found or fail to run, skipping byte measurement"); -- size = 0; -- } -- - ok = g_file_measure_disk_usage (file, - G_FILE_MEASURE_APPARENT_SIZE, - NULL, -@@ -2612,8 +2541,7 @@ test_measure (void) - g_assert_true (ok); - g_assert_no_error (error); - -- if (size > 0) -- g_assert_cmpuint (num_bytes, ==, size); -+ g_assert_cmpuint (num_bytes, ==, 74478); - g_assert_cmpuint (num_dirs, ==, 6); - g_assert_cmpuint (num_files, ==, 32); - -@@ -2665,8 +2593,7 @@ measure_done (GObject *source, - g_assert_true (ok); - g_assert_no_error (error); - -- if (data->expected_bytes > 0) -- g_assert_cmpuint (data->expected_bytes, ==, num_bytes); -+ g_assert_cmpuint (data->expected_bytes, ==, num_bytes); - g_assert_cmpuint (data->expected_dirs, ==, num_dirs); - g_assert_cmpuint (data->expected_files, ==, num_files); - -@@ -2695,15 +2622,9 @@ test_measure_async (void) - - path = g_test_build_filename (G_TEST_DIST, "desktop-files", NULL); - file = g_file_new_for_path (path); -- -- if (!get_size_from_du (path, &data->expected_bytes)) -- { -- g_test_message ("du not found or fail to run, skipping byte measurement"); -- data->expected_bytes = 0; -- } -- - g_free (path); - -+ data->expected_bytes = 74478; - data->expected_dirs = 6; - data->expected_files = 32; - --- -GitLab - diff --git a/backport-gdbusinterfaceskeleton-Fix-a-use-after-free-of-a-GDBusMethodInvocation.patch b/backport-gdbusinterfaceskeleton-Fix-a-use-after-free-of-a-GDBusMethodInvocation.patch deleted file mode 100644 index 666153caefedb3cadf414e1913610789edc0f708..0000000000000000000000000000000000000000 --- a/backport-gdbusinterfaceskeleton-Fix-a-use-after-free-of-a-GDBusMethodInvocation.patch +++ /dev/null @@ -1,182 +0,0 @@ -From 1f86923766a3d1d319fe54ad24fcf6e2d75aca0d Mon Sep 17 00:00:00 2001 -From: Philip Withnall -Date: Wed, 22 Feb 2023 12:40:49 +0000 -Subject: [PATCH 1/3] gdbusinterfaceskeleton: Remove an unnecessary helper - struct member -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -The `GDBusInterfaceSkeleton` is already stored as the source object of -the `GTask` here, with a strong reference. - -Storing it again in the task’s data struct is redundant, and makes it -look like the `GDBusInterfaceSkeleton` is being used without holding a -strong reference. (There’s not actually a bug there though: the strong -reference from the `GTask` outlives the data struct, so is sufficient.) - -Remove the unnecessary helper struct member to clarify the code a bit. - -Signed-off-by: Philip Withnall - -Helps: #2924 ---- - gio/gdbusinterfaceskeleton.c | 15 +++++++-------- - 1 file changed, 7 insertions(+), 8 deletions(-) - -diff --git a/gio/gdbusinterfaceskeleton.c b/gio/gdbusinterfaceskeleton.c -index 3f07d4d0b2..d28282fea3 100644 ---- a/gio/gdbusinterfaceskeleton.c -+++ b/gio/gdbusinterfaceskeleton.c -@@ -461,7 +461,6 @@ dbus_interface_interface_init (GDBusInterfaceIface *iface) - typedef struct - { - gint ref_count; /* (atomic) */ -- GDBusInterfaceSkeleton *interface; - GDBusInterfaceMethodCallFunc method_call_func; - GDBusMethodInvocation *invocation; - } DispatchData; -@@ -502,16 +501,17 @@ dispatch_in_thread_func (GTask *task, - GCancellable *cancellable) - { - DispatchData *data = task_data; -+ GDBusInterfaceSkeleton *interface = g_task_get_source_object (task); - GDBusInterfaceSkeletonFlags flags; - GDBusObject *object; - gboolean authorized; - -- g_mutex_lock (&data->interface->priv->lock); -- flags = data->interface->priv->flags; -- object = data->interface->priv->object; -+ g_mutex_lock (&interface->priv->lock); -+ flags = interface->priv->flags; -+ object = interface->priv->object; - if (object != NULL) - g_object_ref (object); -- g_mutex_unlock (&data->interface->priv->lock); -+ g_mutex_unlock (&interface->priv->lock); - - /* first check on the enclosing object (if any), then the interface */ - authorized = TRUE; -@@ -519,13 +519,13 @@ dispatch_in_thread_func (GTask *task, - { - g_signal_emit_by_name (object, - "authorize-method", -- data->interface, -+ interface, - data->invocation, - &authorized); - } - if (authorized) - { -- g_signal_emit (data->interface, -+ g_signal_emit (interface, - signals[G_AUTHORIZE_METHOD_SIGNAL], - 0, - data->invocation, -@@ -627,7 +627,6 @@ g_dbus_interface_method_dispatch_helper (GDBusInterfaceSkeleton *interface - DispatchData *data; - - data = g_slice_new0 (DispatchData); -- data->interface = interface; - data->method_call_func = method_call_func; - data->invocation = invocation; - data->ref_count = 1; --- -GitLab - - -From d5710deb9d621bcf0cec0ff2db0708f361490752 Mon Sep 17 00:00:00 2001 -From: Philip Withnall -Date: Wed, 22 Feb 2023 12:47:36 +0000 -Subject: [PATCH 2/3] gdbusinterfaceskeleton: Fix a use-after-free of a - GDBusMethodInvocation -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This `GDBusMethodInvocation` may be shared across threads, with no -guarantee on the strong ref in one thread outlasting any refs in other -threads — so it needs a ref in this helper struct. - -This should fix a use-after-free where the `GDBusMethodInvocation` is -freed from `g_value_unset()` after `g_signal_emit()` returns in -`dispatch_in_thread_func()` in one thread; but then dereferenced again -in `g_source_destroy_internal()` from another thread. - -Signed-off-by: Philip Withnall - -Fixes: #2924 ---- - gio/gdbusinterfaceskeleton.c | 9 ++++++--- - 1 file changed, 6 insertions(+), 3 deletions(-) - -diff --git a/gio/gdbusinterfaceskeleton.c b/gio/gdbusinterfaceskeleton.c -index d28282fea3..a2a79fe3d8 100644 ---- a/gio/gdbusinterfaceskeleton.c -+++ b/gio/gdbusinterfaceskeleton.c -@@ -462,14 +462,17 @@ typedef struct - { - gint ref_count; /* (atomic) */ - GDBusInterfaceMethodCallFunc method_call_func; -- GDBusMethodInvocation *invocation; -+ GDBusMethodInvocation *invocation; /* (owned) */ - } DispatchData; - - static void - dispatch_data_unref (DispatchData *data) - { - if (g_atomic_int_dec_and_test (&data->ref_count)) -- g_slice_free (DispatchData, data); -+ { -+ g_clear_object (&data->invocation); -+ g_slice_free (DispatchData, data); -+ } - } - - static DispatchData * -@@ -628,7 +631,7 @@ g_dbus_interface_method_dispatch_helper (GDBusInterfaceSkeleton *interface - - data = g_slice_new0 (DispatchData); - data->method_call_func = method_call_func; -- data->invocation = invocation; -+ data->invocation = g_object_ref (invocation); - data->ref_count = 1; - - task = g_task_new (interface, NULL, NULL, NULL); --- -GitLab - - -From 7b101588e924f3783a0f5075f06b3e1d698be936 Mon Sep 17 00:00:00 2001 -From: Philip Withnall -Date: Wed, 22 Feb 2023 12:50:10 +0000 -Subject: [PATCH 3/3] gdbusconnection: Make GDBusMethodInvocation transfer a - bit clearer - -Add a missing steal call in `schedule_method_call()`. This introduces no -functional changes, but documents the ownership transfer more clearly. - -Signed-off-by: Philip Withnall - -Helps: #2924 ---- - gio/gdbusconnection.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c -index d938f71b99..da6b66f2ec 100644 ---- a/gio/gdbusconnection.c -+++ b/gio/gdbusconnection.c -@@ -5043,7 +5043,7 @@ schedule_method_call (GDBusConnection *connection, - g_source_set_priority (idle_source, G_PRIORITY_DEFAULT); - g_source_set_callback (idle_source, - call_in_idle_cb, -- invocation, -+ g_steal_pointer (&invocation), - g_object_unref); - g_source_set_static_name (idle_source, "[gio, " __FILE__ "] call_in_idle_cb"); - g_source_attach (idle_source, main_context); --- -GitLab - diff --git a/glib-2.74.4.tar.xz b/glib-2.77.0.tar.xz similarity index 41% rename from glib-2.74.4.tar.xz rename to glib-2.77.0.tar.xz index 98cfc3f7633bb27bd64fedec22d83b17aec5721f..7f85966c838e8641b327018be0283fd1c473b11a 100644 Binary files a/glib-2.74.4.tar.xz and b/glib-2.77.0.tar.xz differ diff --git a/glib2.spec b/glib2.spec index 12121ecba2e3dcc3500ffc6146447107555f9037..e125c611199115d5263ea303b53bd9fae5b1d464 100644 --- a/glib2.spec +++ b/glib2.spec @@ -1,13 +1,15 @@ Name: glib2 -Version: 2.74.4 -Release: 3 +Version: 2.77.0 +Release: 1 Summary: The core library that forms the basis for projects such as GTK+ and GNOME License: LGPLv2+ URL: https://www.gtk.org -Source0: https://download.gnome.org/sources/glib/2.74/glib-%{version}.tar.xz +Source0: https://download.gnome.org/sources/glib/2.77/glib-%{version}.tar.xz -patch6001: backport-gdbusinterfaceskeleton-Fix-a-use-after-free-of-a-GDBusMethodInvocation.patch -patch6002: backport-Align-G_FILE_MEASURE_APPARENT_SIZE-behaviour-with-du-from-GNU-coreutils.patch +# https://gitlab.gnome.org/GNOME/glib/-/issues/3054 +# https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3501 +Patch1: 0001-gmain-Add-a-missing-return-on-error-path-in-g_main_c.patch +Patch2: gspawn-eperm.patch BuildRequires: chrpath gcc gcc-c++ gettext perl-interpreter BUildRequires: glibc-devel libattr-devel libselinux-devel meson @@ -201,9 +203,13 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || : %defattr(-,root,root) %{_mandir}/man1/* %doc %{_datadir}/gtk-doc/html/* +%doc %{_datadir}/doc/glib-2.0/* %endif %changelog +* Mon Jul 24 2023 dillon chen - 2.77.0-1 +- Update to 2.77.0 + * Sat Jul 15 2023 hanhuihui - 2.74.4-3 - Align G_FILE_MEASURE_APPARENT_SIZE behaviour with du from GNU coreutils diff --git a/gspawn-eperm.patch b/gspawn-eperm.patch new file mode 100644 index 0000000000000000000000000000000000000000..0fa6bf3a5c2a0b75f4d0c9f093b541b243182a87 --- /dev/null +++ b/gspawn-eperm.patch @@ -0,0 +1,43 @@ +diff --git a/glib/gspawn.c b/glib/gspawn.c +index 67be6a6af..aaefd5b0d 100644 +--- a/glib/gspawn.c ++++ b/glib/gspawn.c +@@ -1598,9 +1598,18 @@ safe_fdwalk_set_cloexec (int lowfd) + * + * Handle ENOSYS in case it’s supported in libc but not the kernel; if so, + * fall back to safe_fdwalk(). Handle EINVAL in case `CLOSE_RANGE_CLOEXEC` +- * is not supported. */ ++ * is not supported. ++ * ++ * Also handle EPERM for the cases where GLib is running under broken versions ++ * of Docker+libseccomp which don’t recognise `close_range()` so block calls ++ * to it under a default security policy which returns EPERM rather than (the ++ * correct) ENOSYS. This workaround should be carried in distributions until ++ * they have versions of libseccomp and Docker which contain: ++ * - https://salsa.debian.org/debian/libseccomp/-/blob/debian/bullseye/debian/patches/syscalls_add_close_range_syscall.patch ++ * - https://github.com/opencontainers/runc/issues/2151 ++ */ + ret = close_range (lowfd, G_MAXUINT, CLOSE_RANGE_CLOEXEC); +- if (ret == 0 || !(errno == ENOSYS || errno == EINVAL)) ++ if (ret == 0 || !(errno == ENOSYS || errno == EINVAL || errno == EPERM)) + return ret; + #endif /* HAVE_CLOSE_RANGE */ + +@@ -1624,9 +1633,15 @@ safe_closefrom (int lowfd) + * situations: https://bugs.python.org/issue38061 + * + * Handle ENOSYS in case it’s supported in libc but not the kernel; if so, +- * fall back to safe_fdwalk(). */ ++ * fall back to safe_fdwalk(). ++ * ++ * Also handle EPERM for the cases where GLib is running under broken versions ++ * of Docker+libseccomp which don’t recognise `close_range()` so block calls ++ * to it under a default security policy which returns EPERM rather than (the ++ * correct) ENOSYS. ++ */ + ret = close_range (lowfd, G_MAXUINT, 0); +- if (ret == 0 || errno != ENOSYS) ++ if (ret == 0 || !(errno == ENOSYS || errno == EPERM)) + return ret; + #endif /* HAVE_CLOSE_RANGE */ +