diff --git a/backport-gcontextspecificgroup-Wait-until-stop_func-is-done.patch b/backport-gcontextspecificgroup-Wait-until-stop_func-is-done.patch new file mode 100644 index 0000000000000000000000000000000000000000..9130d704a5c1dbf1d23e049d0da42948958c66d5 --- /dev/null +++ b/backport-gcontextspecificgroup-Wait-until-stop_func-is-done.patch @@ -0,0 +1,44 @@ +From bf7d941088b4860a93f3ea0f3202f495a9fd0667 Mon Sep 17 00:00:00 2001 +From: Ondrej Holy +Date: Mon, 19 Feb 2024 13:38:00 +0100 +Subject: [PATCH] gcontextspecificgroup: Wait until stop_func is done + +Currently, the `stop_func` is executed on an extra thread, and the +`g_context_specific_group_remove` function returns before the `stop_func` +finishes. It may happen that the `stop_func` is never executed if the +program terminates soon after calling it. Let's wait until the `stop_func` +is done. + +Fixes: https://gitlab.gnome.org/GNOME/glib/-/issues/3258 +--- + gio/gcontextspecificgroup.c | 14 ++------------ + 1 file changed, 2 insertions(+), 12 deletions(-) + +diff --git a/gio/gcontextspecificgroup.c b/gio/gcontextspecificgroup.c +index e1def3bbbd..41a35de86e 100644 +--- a/gio/gcontextspecificgroup.c ++++ b/gio/gcontextspecificgroup.c +@@ -153,18 +153,8 @@ g_context_specific_group_request_state (GContextSpecificGroup *group, + } + } + +- /* we only block for positive transitions */ +- if (requested_state) +- { +- while (group->requested_state != group->effective_state) +- g_cond_wait (&group->cond, &group->lock); +- +- /* there is no way this could go back to FALSE because the object +- * that we just created in this thread would have to have been +- * destroyed again (from this thread) before that could happen. +- */ +- g_assert (group->effective_state); +- } ++ while (group->requested_state != group->effective_state) ++ g_cond_wait (&group->cond, &group->lock); + } + + gpointer +-- +GitLab + diff --git a/backport-gdbusmessage-Clean-the-cached-arg0-when-setting-the-message-body.patch b/backport-gdbusmessage-Clean-the-cached-arg0-when-setting-the-message-body.patch new file mode 100644 index 0000000000000000000000000000000000000000..4623a7827df977ed0b9e73c7636f03f8d10b19a1 --- /dev/null +++ b/backport-gdbusmessage-Clean-the-cached-arg0-when-setting-the-message-body.patch @@ -0,0 +1,43 @@ +From 8966099e9bef3fd3481f87bb7ad933f5cacad885 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= +Date: Wed, 8 May 2024 22:53:51 +0200 +Subject: [PATCH] gdbusmessage: Clean the cached arg0 when setting the message + body + +We're now caching arg0 but such value is not cleared when a new body is +set as it's in the connection filter test cases where we've a leak as +highlighted by both valgrind and leak sanitizer +--- + gio/gdbusmessage.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c +index 0b77dc6079..331e68d453 100644 +--- a/gio/gdbusmessage.c ++++ b/gio/gdbusmessage.c +@@ -1155,10 +1155,12 @@ g_dbus_message_set_body (GDBusMessage *message, + + if (message->body != NULL) + g_variant_unref (message->body); ++ ++ g_clear_pointer (&message->arg0_cache, g_variant_unref); ++ + if (body == NULL) + { + message->body = NULL; +- message->arg0_cache = NULL; + g_dbus_message_set_signature (message, NULL); + } + else +@@ -1172,8 +1174,6 @@ g_dbus_message_set_body (GDBusMessage *message, + if (g_variant_is_of_type (message->body, G_VARIANT_TYPE_TUPLE) && + g_variant_n_children (message->body) > 0) + message->arg0_cache = g_variant_get_child_value (message->body, 0); +- else +- message->arg0_cache = NULL; + + type_string = g_variant_get_type_string (body); + type_string_len = strlen (type_string); +-- +GitLab + diff --git a/backport-gresources-fix-memory-leak-from-libelf.patch b/backport-gresources-fix-memory-leak-from-libelf.patch new file mode 100644 index 0000000000000000000000000000000000000000..d4e897db3cb64adab7a8f69f86c96a546f100496 --- /dev/null +++ b/backport-gresources-fix-memory-leak-from-libelf.patch @@ -0,0 +1,29 @@ +From aa8ed92fba93f6213eab8f50754f427550797bfc Mon Sep 17 00:00:00 2001 +From: Maxim Moskalets +Date: Sat, 3 Feb 2024 15:16:56 +0300 +Subject: [PATCH] gresources: fix memory leak from libelf + +Memory was leaking when allocating it inside libelf and losing the pointer to it (it was an automatic variable) when returning NULL from the get_elf function in some cases + +Closes #3242 + +Signed-off-by: Maxim Moskalets +--- + gio/gresource-tool.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/gio/gresource-tool.c b/gio/gresource-tool.c +index fa7bdedb55..44b1f3f028 100644 +--- a/gio/gresource-tool.c ++++ b/gio/gresource-tool.c +@@ -165,6 +165,7 @@ get_elf (const gchar *file, + + if (elf_kind (elf) != ELF_K_ELF) + { ++ elf_end (elf); + g_close (*fd, NULL); + *fd = -1; + return NULL; +-- +GitLab + diff --git a/backport-gsocketclient-Fix-a-use-after-free-in-g_socket_client_connected_callback.patch b/backport-gsocketclient-Fix-a-use-after-free-in-g_socket_client_connected_callback.patch new file mode 100644 index 0000000000000000000000000000000000000000..2592b3ab5c7b54aea8f66a68606fb4daf97bee8f --- /dev/null +++ b/backport-gsocketclient-Fix-a-use-after-free-in-g_socket_client_connected_callback.patch @@ -0,0 +1,36 @@ +From 9a661ab970d194afc59f9b7cdf603fe4bd66505d Mon Sep 17 00:00:00 2001 +From: Philip Withnall +Date: Mon, 26 Feb 2024 15:26:03 +0000 +Subject: [PATCH] gsocketclient: Fix a use-after-free in + g_socket_client_connected_callback() + +The ref held by `data->task` may be the last one on the `GTask`. The +`GTask` stores `attempt->data` as its task data, and so when the `GTask` +is finalised, `attempt->data` is too. `connection_attempt_remove()` +needs to access `attempt->data`, so must be called before the +`g_object_unref()` in this situation. + +Signed-off-by: Philip Withnall + +Fixes: #3266 +--- + gio/gsocketclient.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gio/gsocketclient.c b/gio/gsocketclient.c +index 1127e4599f..d4231599a5 100644 +--- a/gio/gsocketclient.c ++++ b/gio/gsocketclient.c +@@ -1931,8 +1931,8 @@ g_socket_client_connected_callback (GObject *source, + + if (task_completed_or_cancelled (data) || g_cancellable_is_cancelled (attempt->cancellable)) + { +- g_object_unref (data->task); + connection_attempt_unref (attempt); ++ g_object_unref (data->task); + return; + } + +-- +GitLab + diff --git a/backport-xdgmime-Fix-broken-file-content-type-lookups-for-webkitgtk.patch b/backport-xdgmime-Fix-broken-file-content-type-lookups-for-webkitgtk.patch new file mode 100644 index 0000000000000000000000000000000000000000..c101c5b8dcedb876c060bff6fb5328f2f91de19f --- /dev/null +++ b/backport-xdgmime-Fix-broken-file-content-type-lookups-for-webkitgtk.patch @@ -0,0 +1,59 @@ +From 7ec351e3f48029602e916f11c66468b609befc95 Mon Sep 17 00:00:00 2001 +From: Philip Withnall +Date: Wed, 1 Jun 2022 14:00:01 +0100 +Subject: [PATCH] xdgmime: Fix broken file:// content type lookups for + webkitgtk + +This re-applies a chunk from commit e63262d49d40a36060 which was +accidentally lost when upstreaming the commit to xdgmime (as +https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/10). + +The upstreamed commit was then re-backported to GLib as a1bfe899abe, +without the missing chunk. + +The missing chunk is potentially causing incorrect content type results +for `file://` URIs when used from webkitgtk. + +Thanks to Stephen Jung and Michael Catanzaro for investigating. + +Signed-off-by: Philip Withnall + +Fixes: #2639 +--- + gio/xdgmime/xdgmimecache.c | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +diff --git a/gio/xdgmime/xdgmimecache.c b/gio/xdgmime/xdgmimecache.c +index f80f122a14..234e4b4677 100644 +--- a/gio/xdgmime/xdgmimecache.c ++++ b/gio/xdgmime/xdgmimecache.c +@@ -568,17 +568,17 @@ cache_glob_lookup_suffix (const char *file_name, + n_entries = GET_UINT32 (cache->buffer, list_offset); + offset = GET_UINT32 (cache->buffer, list_offset + 4); + +- n = cache_glob_node_lookup_suffix (cache, +- n_entries, offset, +- file_name, len, +- ignore_case, +- mime_types, +- n_mime_types); +- if (n > 0) +- return n; ++ n += cache_glob_node_lookup_suffix (cache, ++ n_entries, offset, ++ file_name, len, ++ ignore_case, ++ mime_types + n, ++ n_mime_types - n); ++ if (n == n_mime_types) ++ break; + } + +- return 0; ++ return n; + } + + static int compare_mime_weight (const void *a, const void *b) +-- +GitLab + diff --git a/backport-xdgmime-Handle-buggy-type-definitions-with-circular-inheritance.patch b/backport-xdgmime-Handle-buggy-type-definitions-with-circular-inheritance.patch new file mode 100644 index 0000000000000000000000000000000000000000..5f2a765644b5daf533e5692ba295f47aea94317f --- /dev/null +++ b/backport-xdgmime-Handle-buggy-type-definitions-with-circular-inheritance.patch @@ -0,0 +1,265 @@ +From d9c50cac5d160798498e42d5b190ad89920a9a6a Mon Sep 17 00:00:00 2001 +From: Alex Henrie +Date: Sun, 19 Nov 2023 15:54:27 -0700 +Subject: [PATCH 1/2] xdgmime: Handle buggy type definitions with circular + inheritance + +This fixes a stack overflow reported by a user who had both the +definition of text/javascript from shared-mime-info 2.3 and the +definition of text/javascript from shared-mime-info 2.4 installed at the +same time. In 2.3, text/javascript is a subtype of +application/ecmascript, but in 2.4 application/ecmascript is a subtype +of text/javascript. Having both at the same time resulted in circular +inheritance. + +The new logic keeps a list of all parents that have already been +checked, which is more comprehensive than the old workaround that was +implemented in commit 38869ece2 ("xdgmime: Prevent infinite loops from +badly-formed MIME registrations"). + +https://bugs.archlinux.org/task/80279 +--- + gio/xdgmime/xdgmime.c | 43 +++++++++++++++++++++++++++------- + gio/xdgmime/xdgmime.h | 3 ++- + gio/xdgmime/xdgmimecache.c | 47 ++++++++++++++++++++++++++++---------- + gio/xdgmime/xdgmimecache.h | 3 ++- + 4 files changed, 74 insertions(+), 22 deletions(-) + +diff --git a/gio/xdgmime/xdgmime.c b/gio/xdgmime/xdgmime.c +index c3c11625e8..31f352ceee 100644 +--- a/gio/xdgmime/xdgmime.c ++++ b/gio/xdgmime/xdgmime.c +@@ -835,13 +835,16 @@ xdg_mime_is_super_type (const char *mime) + + int + _xdg_mime_mime_type_subclass (const char *mime, +- const char *base) ++ const char *base, ++ const char **seen) + { +- const char *umime, *ubase; ++ const char *umime, *ubase, *parent; + const char **parents; + ++ int first_seen = 0, i, ret = 0; ++ + if (_caches) +- return _xdg_mime_cache_mime_type_subclass (mime, base); ++ return _xdg_mime_cache_mime_type_subclass (mime, base, NULL); + + umime = _xdg_mime_unalias_mime_type (mime); + ubase = _xdg_mime_unalias_mime_type (base); +@@ -864,15 +867,39 @@ _xdg_mime_mime_type_subclass (const char *mime, + if (strcmp (ubase, "application/octet-stream") == 0 && + strncmp (umime, "inode/", 6) != 0) + return 1; +- ++ ++ if (!seen) ++ { ++ seen = calloc (1, sizeof (char *)); ++ first_seen = 1; ++ } ++ + parents = _xdg_mime_parent_list_lookup (parent_list, umime); + for (; parents && *parents; parents++) + { +- if (_xdg_mime_mime_type_subclass (*parents, ubase)) +- return 1; ++ parent = *parents; ++ ++ /* Detect and avoid buggy circular relationships */ ++ for (i = 0; seen[i] != NULL; i++) ++ if (parent == seen[i]) ++ goto next_parent; ++ seen = realloc (seen, (i + 2) * sizeof (char *)); ++ seen[i] = parent; ++ seen[i + 1] = NULL; ++ ++ if (_xdg_mime_mime_type_subclass (parent, ubase, seen)) ++ { ++ ret = 1; ++ goto done; ++ } ++ ++ next_parent: + } + +- return 0; ++done: ++ if (first_seen) ++ free (seen); ++ return ret; + } + + int +@@ -881,7 +908,7 @@ xdg_mime_mime_type_subclass (const char *mime, + { + xdg_mime_init (); + +- return _xdg_mime_mime_type_subclass (mime, base); ++ return _xdg_mime_mime_type_subclass (mime, base, NULL); + } + + char ** +diff --git a/gio/xdgmime/xdgmime.h b/gio/xdgmime/xdgmime.h +index c5909967f2..bbae1be790 100644 +--- a/gio/xdgmime/xdgmime.h ++++ b/gio/xdgmime/xdgmime.h +@@ -125,7 +125,8 @@ void xdg_mime_set_dirs (const char * const *dirs); + int _xdg_mime_mime_type_equal (const char *mime_a, + const char *mime_b); + int _xdg_mime_mime_type_subclass (const char *mime, +- const char *base); ++ const char *base, ++ const char **seen); + const char *_xdg_mime_unalias_mime_type (const char *mime); + + +diff --git a/gio/xdgmime/xdgmimecache.c b/gio/xdgmime/xdgmimecache.c +index 234e4b4677..6b1985082f 100644 +--- a/gio/xdgmime/xdgmimecache.c ++++ b/gio/xdgmime/xdgmimecache.c +@@ -751,8 +751,8 @@ cache_get_mime_type_for_data (const void *data, + /* Pick glob-result R where mime_type inherits from R */ + for (n = 0; n < n_mime_types; n++) + { +- if (mime_types[n] && _xdg_mime_cache_mime_type_subclass(mime_types[n], mime_type)) +- return mime_types[n]; ++ if (mime_types[n] && _xdg_mime_cache_mime_type_subclass (mime_types[n], mime_type, NULL)) ++ return mime_types[n]; + } + if (n == 0) + { +@@ -901,13 +901,14 @@ is_super_type (const char *mime) + + int + _xdg_mime_cache_mime_type_subclass (const char *mime, +- const char *base) ++ const char *base, ++ const char **seen) + { +- const char *umime, *ubase; ++ const char *umime, *ubase, *parent; + + xdg_uint32_t j; +- int i, min, max, med, cmp; +- ++ int i, k, min, max, med, cmp, first_seen = 0, ret = 0; ++ + umime = _xdg_mime_cache_unalias_mime_type (mime); + ubase = _xdg_mime_cache_unalias_mime_type (base); + +@@ -932,7 +933,13 @@ _xdg_mime_cache_mime_type_subclass (const char *mime, + if (strcmp (ubase, "application/octet-stream") == 0 && + strncmp (umime, "inode/", 6) != 0) + return 1; +- ++ ++ if (!seen) ++ { ++ seen = calloc (1, sizeof (char *)); ++ first_seen = 1; ++ } ++ + for (i = 0; _caches[i]; i++) + { + XdgMimeCache *cache = _caches[i]; +@@ -966,10 +973,23 @@ _xdg_mime_cache_mime_type_subclass (const char *mime, + for (j = 0; j < n_parents; j++) + { + parent_offset = GET_UINT32 (cache->buffer, offset + 4 + 4 * j); +- if (strcmp (cache->buffer + parent_offset, mime) != 0 && +- strcmp (cache->buffer + parent_offset, umime) != 0 && +- _xdg_mime_cache_mime_type_subclass (cache->buffer + parent_offset, ubase)) +- return 1; ++ parent = cache->buffer + parent_offset; ++ ++ /* Detect and avoid buggy circular relationships */ ++ for (k = 0; seen[k] != NULL; k++) ++ if (parent == seen[k]) ++ goto next_parent; ++ seen = realloc (seen, (k + 2) * sizeof (char *)); ++ seen[k] = parent; ++ seen[k + 1] = NULL; ++ ++ if (_xdg_mime_cache_mime_type_subclass (parent, ubase, seen)) ++ { ++ ret = 1; ++ goto done; ++ } ++ ++ next_parent: + } + + break; +@@ -977,7 +997,10 @@ _xdg_mime_cache_mime_type_subclass (const char *mime, + } + } + +- return 0; ++done: ++ if (first_seen) ++ free (seen); ++ return ret; + } + + const char * +diff --git a/gio/xdgmime/xdgmimecache.h b/gio/xdgmime/xdgmimecache.h +index df25b2a576..0ac0b054fe 100644 +--- a/gio/xdgmime/xdgmimecache.h ++++ b/gio/xdgmime/xdgmimecache.h +@@ -70,7 +70,8 @@ int _xdg_mime_cache_mime_type_equal (const char *mime_a, + int _xdg_mime_cache_media_type_equal (const char *mime_a, + const char *mime_b); + int _xdg_mime_cache_mime_type_subclass (const char *mime_a, +- const char *mime_b); ++ const char *mime_b, ++ const char **seen); + char **_xdg_mime_cache_list_mime_parents (const char *mime); + const char *_xdg_mime_cache_unalias_mime_type (const char *mime); + int _xdg_mime_cache_get_max_buffer_extents (void); +-- +GitLab + +From 77902e1b1c8ff906a560270656a51a28787b9492 Mon Sep 17 00:00:00 2001 +From: Alex Henrie +Date: Tue, 21 Nov 2023 11:04:50 -0700 +Subject: [PATCH 2/2] xdgmime: Add continue statements after goto labels + in_xdg_mime_(cache_)mime_type_subclass + +To fix the Android build. +--- + gio/xdgmime/xdgmime.c | 1 + + gio/xdgmime/xdgmimecache.c | 3 ++- + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/gio/xdgmime/xdgmime.c b/gio/xdgmime/xdgmime.c +index 31f352ceee..dce938a6f5 100644 +--- a/gio/xdgmime/xdgmime.c ++++ b/gio/xdgmime/xdgmime.c +@@ -894,6 +894,7 @@ _xdg_mime_mime_type_subclass (const char *mime, + } + + next_parent: ++ continue; + } + + done: +diff --git a/gio/xdgmime/xdgmimecache.c b/gio/xdgmime/xdgmimecache.c +index 6b1985082f..9ea10f901d 100644 +--- a/gio/xdgmime/xdgmimecache.c ++++ b/gio/xdgmime/xdgmimecache.c +@@ -989,7 +989,8 @@ _xdg_mime_cache_mime_type_subclass (const char *mime, + goto done; + } + +- next_parent: ++ next_parent: ++ continue; + } + + break; +-- +GitLab + diff --git a/backport-xdgmime-Update-to-upstream-commit-c2c814d.patch b/backport-xdgmime-Update-to-upstream-commit-c2c814d.patch new file mode 100644 index 0000000000000000000000000000000000000000..214cd77026e2a6d74f7e5a06d3d6916841aa4466 --- /dev/null +++ b/backport-xdgmime-Update-to-upstream-commit-c2c814d.patch @@ -0,0 +1,899 @@ +From b097adf18aedbb13b3d0e4cf260c3fede8d8995e Mon Sep 17 00:00:00 2001 +From: Philip Withnall +Date: Mon, 4 Dec 2023 12:40:49 +0000 +Subject: [PATCH] xdgmime: Update to upstream commit c2c814d4051f232 + +(Modulo the changes in +https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/10 which are +still under discussion. Plus the proposed warning fixes from +https://gitlab.freedesktop.org/xdg/xdgmime/-/merge_requests/33.) + +Signed-off-by: Philip Withnall + +Fixes: #3191 +--- + gio/xdgmime/xdgmime.c | 48 ++++++-------- + gio/xdgmime/xdgmime.h | 20 +----- + gio/xdgmime/xdgmimealias.c | 18 +----- + gio/xdgmime/xdgmimealias.h | 18 +----- + gio/xdgmime/xdgmimecache.c | 122 ++++++++++++++++++++++++++---------- + gio/xdgmime/xdgmimecache.h | 20 +----- + gio/xdgmime/xdgmimeglob.c | 18 +----- + gio/xdgmime/xdgmimeglob.h | 18 +----- + gio/xdgmime/xdgmimeicon.c | 18 +----- + gio/xdgmime/xdgmimeicon.h | 18 +----- + gio/xdgmime/xdgmimeint.c | 20 +----- + gio/xdgmime/xdgmimeint.h | 18 +----- + gio/xdgmime/xdgmimemagic.c | 23 ++----- + gio/xdgmime/xdgmimemagic.h | 18 +----- + gio/xdgmime/xdgmimeparent.c | 18 +----- + gio/xdgmime/xdgmimeparent.h | 18 +----- + 16 files changed, 130 insertions(+), 303 deletions(-) + +diff --git a/gio/xdgmime/xdgmime.c b/gio/xdgmime/xdgmime.c +index 31f352c..1a8be22 100644 +--- a/gio/xdgmime/xdgmime.c ++++ b/gio/xdgmime/xdgmime.c +@@ -6,23 +6,7 @@ + * Copyright (C) 2003,2004 Red Hat, Inc. + * Copyright (C) 2003,2004 Jonathan Blandford + * +- * Licensed under the Academic Free License version 2.0 +- * Or under the following terms: +- * +- * This library is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public +- * License as published by the Free Software Foundation; either +- * version 2.1 of the License, or (at your option) any later version. +- * +- * This library is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * Lesser General Public License for more details. +- * +- * You should have received a copy of the GNU Lesser General Public +- * License along with this library; if not, write to the +- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- * Boston, MA 02111-1307, USA. ++ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0 + */ + + #ifdef HAVE_CONFIG_H +@@ -143,7 +127,7 @@ xdg_dir_time_list_free (XdgDirTimeList *list) + + static int + xdg_mime_init_from_directory (const char *directory, +- void *user_data) ++ void *user_data __attribute__((__unused__))) + { + char *file_name; + struct stat st; +@@ -836,12 +820,12 @@ xdg_mime_is_super_type (const char *mime) + int + _xdg_mime_mime_type_subclass (const char *mime, + const char *base, +- const char **seen) ++ const char ***seen) + { + const char *umime, *ubase, *parent; +- const char **parents; ++ const char **parents, **first_seen = NULL, **new_seen; + +- int first_seen = 0, i, ret = 0; ++ int i, ret = 0; + + if (_caches) + return _xdg_mime_cache_mime_type_subclass (mime, base, NULL); +@@ -870,8 +854,8 @@ _xdg_mime_mime_type_subclass (const char *mime, + + if (!seen) + { +- seen = calloc (1, sizeof (char *)); +- first_seen = 1; ++ first_seen = calloc (1, sizeof (char *)); ++ seen = &first_seen; + } + + parents = _xdg_mime_parent_list_lookup (parent_list, umime); +@@ -880,12 +864,15 @@ _xdg_mime_mime_type_subclass (const char *mime, + parent = *parents; + + /* Detect and avoid buggy circular relationships */ +- for (i = 0; seen[i] != NULL; i++) +- if (parent == seen[i]) ++ for (i = 0; (*seen)[i] != NULL; i++) ++ if (parent == (*seen)[i]) + goto next_parent; +- seen = realloc (seen, (i + 2) * sizeof (char *)); +- seen[i] = parent; +- seen[i + 1] = NULL; ++ new_seen = realloc (*seen, (i + 2) * sizeof (char *)); ++ if (!new_seen) ++ goto done; ++ new_seen[i] = parent; ++ new_seen[i + 1] = NULL; ++ *seen = new_seen; + + if (_xdg_mime_mime_type_subclass (parent, ubase, seen)) + { +@@ -897,8 +884,7 @@ _xdg_mime_mime_type_subclass (const char *mime, + } + + done: +- if (first_seen) +- free (seen); ++ free (first_seen); + return ret; + } + +@@ -918,6 +904,8 @@ xdg_mime_list_mime_parents (const char *mime) + char **result; + int i, n; + ++ xdg_mime_init (); ++ + if (_caches) + return _xdg_mime_cache_list_mime_parents (mime); + +diff --git a/gio/xdgmime/xdgmime.h b/gio/xdgmime/xdgmime.h +index bbae1be..093b12a 100644 +--- a/gio/xdgmime/xdgmime.h ++++ b/gio/xdgmime/xdgmime.h +@@ -6,23 +6,7 @@ + * Copyright (C) 2003 Red Hat, Inc. + * Copyright (C) 2003 Jonathan Blandford + * +- * Licensed under the Academic Free License version 2.0 +- * Or under the following terms: +- * +- * This library is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public +- * License as published by the Free Software Foundation; either +- * version 2.1 of the License, or (at your option) any later version. +- * +- * This library is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * Lesser General Public License for more details. +- * +- * You should have received a copy of the GNU Lesser General Public +- * License along with this library; if not, write to the +- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- * Boston, MA 02111-1307, USA. ++ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0 + */ + + +@@ -126,7 +110,7 @@ int _xdg_mime_mime_type_equal (const char *mime_a, + const char *mime_b); + int _xdg_mime_mime_type_subclass (const char *mime, + const char *base, +- const char **seen); ++ const char ***seen); + const char *_xdg_mime_unalias_mime_type (const char *mime); + + +diff --git a/gio/xdgmime/xdgmimealias.c b/gio/xdgmime/xdgmimealias.c +index 0fc51f9..857d274 100644 +--- a/gio/xdgmime/xdgmimealias.c ++++ b/gio/xdgmime/xdgmimealias.c +@@ -6,23 +6,7 @@ + * Copyright (C) 2004 Red Hat, Inc. + * Copyright (C) 2004 Matthias Clasen + * +- * Licensed under the Academic Free License version 2.0 +- * Or under the following terms: +- * +- * This library is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public +- * License as published by the Free Software Foundation; either +- * version 2.1 of the License, or (at your option) any later version. +- * +- * This library is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * Lesser General Public License for more details. +- * +- * You should have received a copy of the GNU Lesser General Public +- * License along with this library; if not, write to the +- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- * Boston, MA 02111-1307, USA. ++ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0 + */ + + #ifdef HAVE_CONFIG_H +diff --git a/gio/xdgmime/xdgmimealias.h b/gio/xdgmime/xdgmimealias.h +index 6e0cfff..05df009 100644 +--- a/gio/xdgmime/xdgmimealias.h ++++ b/gio/xdgmime/xdgmimealias.h +@@ -6,23 +6,7 @@ + * Copyright (C) 2004 Red Hat, Inc. + * Copyright (C) 200 Matthias Clasen + * +- * Licensed under the Academic Free License version 2.0 +- * Or under the following terms: +- * +- * This library is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public +- * License as published by the Free Software Foundation; either +- * version 2.1 of the License, or (at your option) any later version. +- * +- * This library is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * Lesser General Public License for more details. +- * +- * You should have received a copy of the GNU Lesser General Public +- * License along with this library; if not, write to the +- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- * Boston, MA 02111-1307, USA. ++ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0 + */ + + #ifndef __XDG_MIME_ALIAS_H__ +diff --git a/gio/xdgmime/xdgmimecache.c b/gio/xdgmime/xdgmimecache.c +index 6b19850..5bff3d7 100644 +--- a/gio/xdgmime/xdgmimecache.c ++++ b/gio/xdgmime/xdgmimecache.c +@@ -5,23 +5,7 @@ + * + * Copyright (C) 2005 Matthias Clasen + * +- * Licensed under the Academic Free License version 2.0 +- * Or under the following terms: +- * +- * This library is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public +- * License as published by the Free Software Foundation; either +- * version 2.1 of the License, or (at your option) any later version. +- * +- * This library is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * Lesser General Public License for more details. +- * +- * You should have received a copy of the GNU Lesser General Public +- * License along with this library; if not, write to the +- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- * Boston, MA 02111-1307, USA. ++ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0 + */ + + #ifdef HAVE_CONFIG_H +@@ -92,6 +76,13 @@ struct _XdgMimeCache + #define GET_UINT16(cache,offset) (ntohs(*(xdg_uint16_t*)((cache) + (offset)))) + #define GET_UINT32(cache,offset) (ntohl(*(xdg_uint32_t*)((cache) + (offset)))) + ++// Validates that it is safe to call GET_UINT32() at ++// cache->buffer[offset + (n * record_size)]. Ensures that offset is aligned to ++// a 4-byte boundary, and that offset+(n*record_size) does not overflow. ++// `record_size` values are known constants and never 0. ++#define OUT_OF_BOUNDS(offset,n,record_size,max) \ ++ (((offset) & 0x3) || (offset) > (max) || (n) > ((max) - (offset)) / (record_size)) ++ + XdgMimeCache * + _xdg_mime_cache_ref (XdgMimeCache *cache) + { +@@ -132,7 +123,8 @@ _xdg_mime_cache_new_from_file (const char *file_name) + if (fd < 0) + return NULL; + +- if (fstat (fd, &st) < 0 || st.st_size < 4) ++ // A valid cache must be at least 40 bytes for the header. ++ if (fstat (fd, &st) < 0 || st.st_size < 40) + goto done; + + buffer = (char *) mmap (NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); +@@ -225,8 +217,10 @@ cache_magic_matchlet_compare (XdgMimeCache *cache, + { + xdg_uint32_t n_children = GET_UINT32 (cache->buffer, offset + 24); + xdg_uint32_t child_offset = GET_UINT32 (cache->buffer, offset + 28); +- + xdg_uint32_t i; ++ ++ if (OUT_OF_BOUNDS (child_offset, n_children, 32, cache->size)) ++ return FALSE; + + if (cache_magic_matchlet_compare_to_data (cache, offset, data, len)) + { +@@ -255,9 +249,11 @@ cache_magic_compare_to_data (XdgMimeCache *cache, + xdg_uint32_t mimetype_offset = GET_UINT32 (cache->buffer, offset + 4); + xdg_uint32_t n_matchlets = GET_UINT32 (cache->buffer, offset + 8); + xdg_uint32_t matchlet_offset = GET_UINT32 (cache->buffer, offset + 12); +- + xdg_uint32_t i; + ++ if (OUT_OF_BOUNDS (matchlet_offset, n_matchlets, 32, cache->size)) ++ return NULL; ++ + for (i = 0; i < n_matchlets; i++) + { + if (cache_magic_matchlet_compare (cache, matchlet_offset + i * 32, +@@ -287,8 +283,13 @@ cache_magic_lookup_data (XdgMimeCache *cache, + *prio = 0; + + list_offset = GET_UINT32 (cache->buffer, 24); ++ if (OUT_OF_BOUNDS (list_offset, 1, 12, cache->size)) ++ return NULL; ++ + n_entries = GET_UINT32 (cache->buffer, list_offset); + offset = GET_UINT32 (cache->buffer, list_offset + 8); ++ if (OUT_OF_BOUNDS (offset, n_entries, 16, cache->size)) ++ return NULL; + + for (j = 0; j < n_entries; j++) + { +@@ -320,7 +321,12 @@ cache_alias_lookup (const char *alias) + continue; + + list_offset = GET_UINT32 (cache->buffer, 4); ++ if (OUT_OF_BOUNDS (list_offset, 1, 4, cache->size)) ++ continue; ++ + n_entries = GET_UINT32 (cache->buffer, list_offset); ++ if (OUT_OF_BOUNDS (list_offset + 4, n_entries, 8, cache->size)) ++ continue; + + min = 0; + max = n_entries - 1; +@@ -361,6 +367,8 @@ cache_glob_lookup_literal (const char *file_name, + const char *ptr; + int i, min, max, mid, cmp; + ++ assert (n_mime_types > 0); ++ + for (i = 0; _caches[i]; i++) + { + XdgMimeCache *cache = _caches[i]; +@@ -372,7 +380,12 @@ cache_glob_lookup_literal (const char *file_name, + continue; + + list_offset = GET_UINT32 (cache->buffer, 12); ++ if (OUT_OF_BOUNDS (list_offset, 1, 4, cache->size)) ++ continue; ++ + n_entries = GET_UINT32 (cache->buffer, list_offset); ++ if (OUT_OF_BOUNDS (list_offset + 4, n_entries, 12, cache->size)) ++ continue; + + min = 0; + max = n_entries - 1; +@@ -433,7 +446,12 @@ cache_glob_lookup_fnmatch (const char *file_name, + continue; + + list_offset = GET_UINT32 (cache->buffer, 20); ++ if (OUT_OF_BOUNDS (list_offset, 1, 4, cache->size)) ++ continue; ++ + n_entries = GET_UINT32 (cache->buffer, list_offset); ++ if (OUT_OF_BOUNDS (list_offset + 4, n_entries, 12, cache->size)) ++ continue; + + for (j = 0; j < n_entries && n < n_mime_types; j++) + { +@@ -504,6 +522,8 @@ cache_glob_node_lookup_suffix (XdgMimeCache *cache, + n = 0; + n_children = GET_UINT32 (cache->buffer, offset + 12 * mid + 4); + child_offset = GET_UINT32 (cache->buffer, offset + 12 * mid + 8); ++ if (OUT_OF_BOUNDS (child_offset, n_children, 12, cache->size)) ++ continue; + + if (len > 0) + { +@@ -565,8 +585,13 @@ cache_glob_lookup_suffix (const char *file_name, + continue; + + list_offset = GET_UINT32 (cache->buffer, 16); ++ if (OUT_OF_BOUNDS (list_offset, 1, 8, cache->size)) ++ continue; ++ + n_entries = GET_UINT32 (cache->buffer, list_offset); + offset = GET_UINT32 (cache->buffer, list_offset + 4); ++ if (OUT_OF_BOUNDS (offset, n_entries, 12, cache->size)) ++ continue; + + n += cache_glob_node_lookup_suffix (cache, + n_entries, offset, +@@ -707,6 +732,9 @@ _xdg_mime_cache_get_max_buffer_extents (void) + continue; + + offset = GET_UINT32 (cache->buffer, 24); ++ if (OUT_OF_BOUNDS (offset, 1, 8, cache->size)) ++ continue; ++ + max_extent = MAX (max_extent, GET_UINT32 (cache->buffer, offset + 4)); + } + +@@ -902,12 +930,13 @@ is_super_type (const char *mime) + int + _xdg_mime_cache_mime_type_subclass (const char *mime, + const char *base, +- const char **seen) ++ const char ***seen) + { + const char *umime, *ubase, *parent; ++ const char **first_seen = NULL, **new_seen; + + xdg_uint32_t j; +- int i, k, min, max, med, cmp, first_seen = 0, ret = 0; ++ int i, k, min, max, med, cmp, ret = 0; + + umime = _xdg_mime_cache_unalias_mime_type (mime); + ubase = _xdg_mime_cache_unalias_mime_type (base); +@@ -936,8 +965,8 @@ _xdg_mime_cache_mime_type_subclass (const char *mime, + + if (!seen) + { +- seen = calloc (1, sizeof (char *)); +- first_seen = 1; ++ first_seen = calloc (1, sizeof (char *)); ++ seen = &first_seen; + } + + for (i = 0; _caches[i]; i++) +@@ -951,7 +980,12 @@ _xdg_mime_cache_mime_type_subclass (const char *mime, + continue; + + list_offset = GET_UINT32 (cache->buffer, 8); ++ if (OUT_OF_BOUNDS (list_offset, 1, 4, cache->size)) ++ continue; ++ + n_entries = GET_UINT32 (cache->buffer, list_offset); ++ if (OUT_OF_BOUNDS (list_offset + 4, n_entries, 8, cache->size)) ++ continue; + + min = 0; + max = n_entries - 1; +@@ -976,12 +1010,15 @@ _xdg_mime_cache_mime_type_subclass (const char *mime, + parent = cache->buffer + parent_offset; + + /* Detect and avoid buggy circular relationships */ +- for (k = 0; seen[k] != NULL; k++) +- if (parent == seen[k]) ++ for (k = 0; (*seen)[k] != NULL; k++) ++ if (parent == (*seen)[k]) + goto next_parent; +- seen = realloc (seen, (k + 2) * sizeof (char *)); +- seen[k] = parent; +- seen[k + 1] = NULL; ++ new_seen = realloc (*seen, (k + 2) * sizeof (char *)); ++ if (!new_seen) ++ goto done; ++ new_seen[k] = parent; ++ new_seen[k + 1] = NULL; ++ *seen = new_seen; + + if (_xdg_mime_cache_mime_type_subclass (parent, ubase, seen)) + { +@@ -998,8 +1035,7 @@ _xdg_mime_cache_mime_type_subclass (const char *mime, + } + + done: +- if (first_seen) +- free (seen); ++ free (first_seen); + return ret; + } + +@@ -1037,7 +1073,12 @@ _xdg_mime_cache_list_mime_parents (const char *mime) + continue; + + list_offset = GET_UINT32 (cache->buffer, 8); ++ if (OUT_OF_BOUNDS (list_offset, 1, 4, cache->size)) ++ continue; ++ + n_entries = GET_UINT32 (cache->buffer, list_offset); ++ if (OUT_OF_BOUNDS (list_offset + 4, n_entries, 8, cache->size)) ++ continue; + + for (j = 0; j < n_entries; j++) + { +@@ -1079,7 +1120,7 @@ _xdg_mime_cache_list_mime_parents (const char *mime) + } + + static const char * +-cache_lookup_icon (const char *mime, int header) ++cache_lookup_icon (const char *mime, size_t header) + { + const char *ptr; + int i, min, max, mid, cmp; +@@ -1094,8 +1135,16 @@ cache_lookup_icon (const char *mime, int header) + if (cache->buffer == NULL) + continue; + ++ if (OUT_OF_BOUNDS (header, 1, 4, cache->size)) ++ continue; ++ + list_offset = GET_UINT32 (cache->buffer, header); ++ if (OUT_OF_BOUNDS (list_offset, 1, 4, cache->size)) ++ continue; ++ + n_entries = GET_UINT32 (cache->buffer, list_offset); ++ if (OUT_OF_BOUNDS (list_offset + 4, n_entries, 8, cache->size)) ++ continue; + + min = 0; + max = n_entries - 1; +@@ -1150,6 +1199,9 @@ dump_glob_node (XdgMimeCache *cache, + mime_offset = GET_UINT32 (cache->buffer, offset + 4); + n_children = GET_UINT32 (cache->buffer, offset + 8); + child_offset = GET_UINT32 (cache->buffer, offset + 12); ++ if (OUT_OF_BOUNDS (child_offset, n_children, 20, cache->size)) ++ return; ++ + for (i = 0; i < depth; i++) + printf (" "); + printf ("%c", character); +@@ -1174,12 +1226,18 @@ _xdg_mime_cache_glob_dump (void) + xdg_uint32_t n_entries; + xdg_uint32_t offset; + +- if (cache->buffer == NULL) +- continue; ++ if (cache->buffer == NULL) ++ continue; + + list_offset = GET_UINT32 (cache->buffer, 16); ++ if (OUT_OF_BOUNDS (list_offset, 1, 8, cache->size)) ++ return; ++ + n_entries = GET_UINT32 (cache->buffer, list_offset); + offset = GET_UINT32 (cache->buffer, list_offset + 4); ++ if (OUT_OF_BOUNDS (offset, n_entries, 20, cache->size)) ++ return; ++ + for (j = 0; j < n_entries; j++) + dump_glob_node (cache, offset + 20 * j, 0); + } +diff --git a/gio/xdgmime/xdgmimecache.h b/gio/xdgmime/xdgmimecache.h +index 0ac0b05..de7e531 100644 +--- a/gio/xdgmime/xdgmimecache.h ++++ b/gio/xdgmime/xdgmimecache.h +@@ -5,23 +5,7 @@ + * + * Copyright (C) 2005 Matthias Clasen + * +- * Licensed under the Academic Free License version 2.0 +- * Or under the following terms: +- * +- * This library is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public +- * License as published by the Free Software Foundation; either +- * version 2.1 of the License, or (at your option) any later version. +- * +- * This library is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * Lesser General Public License for more details. +- * +- * You should have received a copy of the GNU Lesser General Public +- * License along with this library; if not, write to the +- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- * Boston, MA 02111-1307, USA. ++ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0 + */ + + #ifndef __XDG_MIME_CACHE_H__ +@@ -71,7 +55,7 @@ int _xdg_mime_cache_media_type_equal (const char *mime_a, + const char *mime_b); + int _xdg_mime_cache_mime_type_subclass (const char *mime_a, + const char *mime_b, +- const char **seen); ++ const char ***seen); + char **_xdg_mime_cache_list_mime_parents (const char *mime); + const char *_xdg_mime_cache_unalias_mime_type (const char *mime); + int _xdg_mime_cache_get_max_buffer_extents (void); +diff --git a/gio/xdgmime/xdgmimeglob.c b/gio/xdgmime/xdgmimeglob.c +index d68435c..e845808 100644 +--- a/gio/xdgmime/xdgmimeglob.c ++++ b/gio/xdgmime/xdgmimeglob.c +@@ -6,23 +6,7 @@ + * Copyright (C) 2003 Red Hat, Inc. + * Copyright (C) 2003 Jonathan Blandford + * +- * Licensed under the Academic Free License version 2.0 +- * Or under the following terms: +- * +- * This library is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public +- * License as published by the Free Software Foundation; either +- * version 2.1 of the License, or (at your option) any later version. +- * +- * This library is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * Lesser General Public License for more details. +- * +- * You should have received a copy of the GNU Lesser General Public +- * License along with this library; if not, write to the +- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- * Boston, MA 02111-1307, USA. ++ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0 + */ + + #ifdef HAVE_CONFIG_H +diff --git a/gio/xdgmime/xdgmimeglob.h b/gio/xdgmime/xdgmimeglob.h +index 8b1fa3a..7ecee9a 100644 +--- a/gio/xdgmime/xdgmimeglob.h ++++ b/gio/xdgmime/xdgmimeglob.h +@@ -6,23 +6,7 @@ + * Copyright (C) 2003 Red Hat, Inc. + * Copyright (C) 2003 Jonathan Blandford + * +- * Licensed under the Academic Free License version 2.0 +- * Or under the following terms: +- * +- * This library is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public +- * License as published by the Free Software Foundation; either +- * version 2.1 of the License, or (at your option) any later version. +- * +- * This library is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * Lesser General Public License for more details. +- * +- * You should have received a copy of the GNU Lesser General Public +- * License along with this library; if not, write to the +- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- * Boston, MA 02111-1307, USA. ++ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0 + */ + + #ifndef __XDG_MIME_GLOB_H__ +diff --git a/gio/xdgmime/xdgmimeicon.c b/gio/xdgmime/xdgmimeicon.c +index feb6c86..4aaa564 100644 +--- a/gio/xdgmime/xdgmimeicon.c ++++ b/gio/xdgmime/xdgmimeicon.c +@@ -5,23 +5,7 @@ + * + * Copyright (C) 2008 Red Hat, Inc. + * +- * Licensed under the Academic Free License version 2.0 +- * Or under the following terms: +- * +- * This library is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public +- * License as published by the Free Software Foundation; either +- * version 2.1 of the License, or (at your option) any later version. +- * +- * This library is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * Lesser General Public License for more details. +- * +- * You should have received a copy of the GNU Lesser General Public +- * License along with this library; if not, write to the +- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- * Boston, MA 02111-1307, USA. ++ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0 + */ + + #ifdef HAVE_CONFIG_H +diff --git a/gio/xdgmime/xdgmimeicon.h b/gio/xdgmime/xdgmimeicon.h +index c416b3c..f724430 100644 +--- a/gio/xdgmime/xdgmimeicon.h ++++ b/gio/xdgmime/xdgmimeicon.h +@@ -5,23 +5,7 @@ + * + * Copyright (C) 2008 Red Hat, Inc. + * +- * Licensed under the Academic Free License version 2.0 +- * Or under the following terms: +- * +- * This library is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public +- * License as published by the Free Software Foundation; either +- * version 2.1 of the License, or (at your option) any later version. +- * +- * This library is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * Lesser General Public License for more details. +- * +- * You should have received a copy of the GNU Lesser General Public +- * License along with this library; if not, write to the +- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- * Boston, MA 02111-1307, USA. ++ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0 + */ + + #ifndef __XDG_MIME_ICON_H__ +diff --git a/gio/xdgmime/xdgmimeint.c b/gio/xdgmime/xdgmimeint.c +index 5e4513c..f7ab067 100644 +--- a/gio/xdgmime/xdgmimeint.c ++++ b/gio/xdgmime/xdgmimeint.c +@@ -6,23 +6,7 @@ + * Copyright (C) 2003 Red Hat, Inc. + * Copyright (C) 2003 Jonathan Blandford + * +- * Licensed under the Academic Free License version 2.0 +- * Or under the following terms: +- * +- * This library is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public +- * License as published by the Free Software Foundation; either +- * version 2.1 of the License, or (at your option) any later version. +- * +- * This library is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * Lesser General Public License for more details. +- * +- * You should have received a copy of the GNU Lesser General Public +- * License along with this library; if not, write to the +- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- * Boston, MA 02111-1307, USA. ++ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0 + */ + + #ifdef HAVE_CONFIG_H +@@ -131,7 +115,7 @@ _xdg_ucs4_to_lower (xdg_unichar_t source) + } + + int +-_xdg_utf8_validate (const char *source) ++_xdg_utf8_validate (const char *source __attribute__((unused))) + { + /* FIXME: actually write */ + return TRUE; +diff --git a/gio/xdgmime/xdgmimeint.h b/gio/xdgmime/xdgmimeint.h +index 9a8256d..041c4f4 100644 +--- a/gio/xdgmime/xdgmimeint.h ++++ b/gio/xdgmime/xdgmimeint.h +@@ -6,23 +6,7 @@ + * Copyright (C) 2003 Red Hat, Inc. + * Copyright (C) 2003 Jonathan Blandford + * +- * Licensed under the Academic Free License version 2.0 +- * Or under the following terms: +- * +- * This library is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public +- * License as published by the Free Software Foundation; either +- * version 2.1 of the License, or (at your option) any later version. +- * +- * This library is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * Lesser General Public License for more details. +- * +- * You should have received a copy of the GNU Lesser General Public +- * License along with this library; if not, write to the +- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- * Boston, MA 02111-1307, USA. ++ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0 + */ + + #ifndef __XDG_MIME_INT_H__ +diff --git a/gio/xdgmime/xdgmimemagic.c b/gio/xdgmime/xdgmimemagic.c +index dcee0fd..98a1274 100644 +--- a/gio/xdgmime/xdgmimemagic.c ++++ b/gio/xdgmime/xdgmimemagic.c +@@ -6,23 +6,7 @@ + * Copyright (C) 2003 Red Hat, Inc. + * Copyright (C) 2003 Jonathan Blandford + * +- * Licensed under the Academic Free License version 2.0 +- * Or under the following terms: +- * +- * This library is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public +- * License as published by the Free Software Foundation; either +- * version 2.1 of the License, or (at your option) any later version. +- * +- * This library is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * Lesser General Public License for more details. +- * +- * You should have received a copy of the GNU Lesser General Public +- * License along with this library; if not, write to the +- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- * Boston, MA 02111-1307, USA. ++ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0 + */ + + #ifdef HAVE_CONFIG_H +@@ -798,6 +782,11 @@ _xdg_mime_magic_read_magic_file (XdgMimeMagic *mime_magic, + break; + case XDG_MIME_MAGIC_ERROR: + state = _xdg_mime_magic_parse_error (magic_file); ++ ++ /* After a parse error we can only be at EOF or reset to starting a ++ * new section. */ ++ assert (state == XDG_MIME_MAGIC_EOF || state == XDG_MIME_MAGIC_SECTION); ++ + break; + case XDG_MIME_MAGIC_EOF: + default: +diff --git a/gio/xdgmime/xdgmimemagic.h b/gio/xdgmime/xdgmimemagic.h +index eb06a81..81125c2 100644 +--- a/gio/xdgmime/xdgmimemagic.h ++++ b/gio/xdgmime/xdgmimemagic.h +@@ -6,23 +6,7 @@ + * Copyright (C) 2003 Red Hat, Inc. + * Copyright (C) 2003 Jonathan Blandford + * +- * Licensed under the Academic Free License version 2.0 +- * Or under the following terms: +- * +- * This library is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public +- * License as published by the Free Software Foundation; either +- * version 2.1 of the License, or (at your option) any later version. +- * +- * This library is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * Lesser General Public License for more details. +- * +- * You should have received a copy of the GNU Lesser General Public +- * License along with this library; if not, write to the +- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- * Boston, MA 02111-1307, USA. ++ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0 + */ + + #ifndef __XDG_MIME_MAGIC_H__ +diff --git a/gio/xdgmime/xdgmimeparent.c b/gio/xdgmime/xdgmimeparent.c +index 89b48fc..e03a78f 100644 +--- a/gio/xdgmime/xdgmimeparent.c ++++ b/gio/xdgmime/xdgmimeparent.c +@@ -6,23 +6,7 @@ + * Copyright (C) 2004 Red Hat, Inc. + * Copyright (C) 2004 Matthias Clasen + * +- * Licensed under the Academic Free License version 2.0 +- * Or under the following terms: +- * +- * This library is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public +- * License as published by the Free Software Foundation; either +- * version 2.1 of the License, or (at your option) any later version. +- * +- * This library is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * Lesser General Public License for more details. +- * +- * You should have received a copy of the GNU Lesser General Public +- * License along with this library; if not, write to the +- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- * Boston, MA 02111-1307, USA. ++ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0 + */ + + #ifdef HAVE_CONFIG_H +diff --git a/gio/xdgmime/xdgmimeparent.h b/gio/xdgmime/xdgmimeparent.h +index 29f43bc..b656e38 100644 +--- a/gio/xdgmime/xdgmimeparent.h ++++ b/gio/xdgmime/xdgmimeparent.h +@@ -6,23 +6,7 @@ + * Copyright (C) 2004 Red Hat, Inc. + * Copyright (C) 200 Matthias Clasen + * +- * Licensed under the Academic Free License version 2.0 +- * Or under the following terms: +- * +- * This library is free software; you can redistribute it and/or +- * modify it under the terms of the GNU Lesser General Public +- * License as published by the Free Software Foundation; either +- * version 2.1 of the License, or (at your option) any later version. +- * +- * This library is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +- * Lesser General Public License for more details. +- * +- * You should have received a copy of the GNU Lesser General Public +- * License along with this library; if not, write to the +- * Free Software Foundation, Inc., 59 Temple Place - Suite 330, +- * Boston, MA 02111-1307, USA. ++ * SPDX-License-Identifier: LGPL-2.1-or-later or AFL-2.0 + */ + + #ifndef __XDG_MIME_PARENT_H__ +-- +2.33.0 + diff --git a/glib2.spec b/glib2.spec index d6e6d8688333c60ce5f501f01c695595a3eb1c06..933de52356f31fa5ac0ff2c17c9e3c10b6c194c6 100644 --- a/glib2.spec +++ b/glib2.spec @@ -1,6 +1,6 @@ Name: glib2 Version: 2.72.2 -Release: 15 +Release: 16 Summary: The core library that forms the basis for projects such as GTK+ and GNOME License: LGPLv2+ URL: http://www.gtk.org @@ -78,6 +78,13 @@ Patch6067: backport-gmessages-fix-dropping-irrelevant-log-domains.patch Patch6068: backport-gutils-Fix-an-unlikely-minor-leak-in-g_build_user_data_dir.patch patch6069: backport-CVE-2024-34397.patch patch6070: backport-gdbusconnection-Allow-name-owners-to-have-the-syntax-of-a-well-known-name.patch +patch6071: backport-xdgmime-Handle-buggy-type-definitions-with-circular-inheritance.patch +patch6072: backport-xdgmime-Fix-broken-file-content-type-lookups-for-webkitgtk.patch +patch6073: backport-xdgmime-Update-to-upstream-commit-c2c814d.patch +patch6074: backport-gresources-fix-memory-leak-from-libelf.patch +patch6075: backport-gcontextspecificgroup-Wait-until-stop_func-is-done.patch +patch6076: backport-gsocketclient-Fix-a-use-after-free-in-g_socket_client_connected_callback.patch +patch6077: backport-gdbusmessage-Clean-the-cached-arg0-when-setting-the-message-body.patch BuildRequires: chrpath gcc gcc-c++ gettext perl-interpreter BUildRequires: glibc-devel libattr-devel libselinux-devel meson @@ -264,6 +271,9 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || : %endif %changelog +* Sat Oct 19 2024 hanhuihui - 2.72.2-16 +- fix memory leak, xdg error, gdbus arg0 error + * Tue Jun 18 2024 hanhuihui - 2.72.2-15 - fix CVE-2024-34397