!119 backport some patches from community

From: @han_hui_hui 
Reviewed-by: @yanan-rock 
Signed-off-by: @yanan-rock
This commit is contained in:
openeuler-ci-bot 2022-12-27 08:16:28 +00:00 committed by Gitee
commit 2c1c705362
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
8 changed files with 409 additions and 1 deletions

View File

@ -0,0 +1,68 @@
From d9ba6150909818beb05573f54f26232063492c5b Mon Sep 17 00:00:00 2001
From: Emmanuel Fleury <emmanuel.fleury@gmail.com>
Date: Mon, 1 Aug 2022 19:05:14 +0200
Subject: [PATCH] Handling collision between standard i/o file descriptors and
newly created ones
Though unlikely to happen, it may happen that newly created file
descriptor take the value 0 (stdin), 1 (stdout) or 2 (stderr) if one
of the standard ones have been dismissed in between. So, it may
confuse the program if it is unaware of this change.
The point of this patch is to avoid a reasign of standard file
descriptors on newly created ones.
Closes issue #16
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/d9ba6150909818beb05573f54f26232063492c5b
---
glib/glib-unix.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/glib/glib-unix.c b/glib/glib-unix.c
index d2dea10ef0..d67b8a357a 100644
--- a/glib/glib-unix.c
+++ b/glib/glib-unix.c
@@ -108,6 +108,17 @@ g_unix_open_pipe (int *fds,
ecode = pipe2 (fds, pipe2_flags);
if (ecode == -1 && errno != ENOSYS)
return g_unix_set_error_from_errno (error, errno);
+ /* Don't reassign pipes to stdin, stdout, stderr if closed meanwhile */
+ else if (fds[0] < 3 || fds[1] < 3)
+ {
+ int old_fds[2] = { fds[0], fds[1] };
+ gboolean result = g_unix_open_pipe (fds, flags, error);
+ close (old_fds[0]);
+ close (old_fds[1]);
+
+ if (!result)
+ g_unix_set_error_from_errno (error, errno);
+ }
else if (ecode == 0)
return TRUE;
/* Fall through on -ENOSYS, we must be running on an old kernel */
@@ -116,6 +127,19 @@ g_unix_open_pipe (int *fds,
ecode = pipe (fds);
if (ecode == -1)
return g_unix_set_error_from_errno (error, errno);
+ /* Don't reassign pipes to stdin, stdout, stderr if closed meanwhile */
+ else if (fds[0] < 3 || fds[1] < 3)
+ {
+ int old_fds[2] = { fds[0], fds[1] };
+ gboolean result = g_unix_open_pipe (fds, flags, error);
+ close (old_fds[0]);
+ close (old_fds[1]);
+
+ if (!result)
+ g_unix_set_error_from_errno (error, errno);
+
+ return result;
+ }
if (flags == 0)
return TRUE;
--
GitLab

View File

@ -0,0 +1,34 @@
From 27203e48c91ab8b55033dcf1773cb60c0aaed3fa Mon Sep 17 00:00:00 2001
From: Sebastian Keller <skeller@gnome.org>
Date: Tue, 30 Aug 2022 21:39:36 +0200
Subject: [PATCH] documentportal: Fix small leak in add_documents with empty
URI list
When called with an empty URI list (or only inaccessible files),
g_document_portal_add_documents would not call g_variant_builder_end,
leaking the memory allocated by the variant builder.
Closes: https://gitlab.gnome.org/GNOME/glib/-/issues/2733
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/27203e48c91ab8b55033dcf1773cb60c0aaed3fa
---
gio/gdocumentportal.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/gio/gdocumentportal.c b/gio/gdocumentportal.c
index c08c36c581..382e2aab6e 100644
--- a/gio/gdocumentportal.c
+++ b/gio/gdocumentportal.c
@@ -203,6 +203,7 @@ g_document_portal_add_documents (GList *uris,
else
{
ruris = g_list_copy_deep (uris, (GCopyFunc)g_strdup, NULL);
+ g_variant_builder_clear (&builder);
}
out:
--
GitLab

View File

@ -0,0 +1,48 @@
From 221f22b6e18fdd306e676e28a79afd3697bddd03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
Date: Fri, 2 Sep 2022 20:38:46 +0200
Subject: [PATCH] gdesktopappinfo: Unref the GDBus call results
On our GDBus call callback wrapper we were completing the gdbus call but
ignoring the returned value, that was always leaked.
Fix this.
Helps with: https://gitlab.gnome.org/GNOME/glib/-/issues/333
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/221f22b6e18fdd306e676e28a79afd3697bddd03
---
gio/gdesktopappinfo.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index af2311ca52..52d308f540 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -3283,15 +3283,19 @@ launch_uris_with_dbus_cb (GObject *object,
{
GTask *task = G_TASK (user_data);
GError *error = NULL;
+ GVariant *ret;
- g_dbus_connection_call_finish (G_DBUS_CONNECTION (object), result, &error);
+ ret = g_dbus_connection_call_finish (G_DBUS_CONNECTION (object), result, &error);
if (error != NULL)
{
g_dbus_error_strip_remote_error (error);
g_task_return_error (task, g_steal_pointer (&error));
}
else
- g_task_return_boolean (task, TRUE);
+ {
+ g_task_return_boolean (task, TRUE);
+ g_variant_unref (ret);
+ }
g_object_unref (task);
}
--
GitLab

View File

@ -0,0 +1,29 @@
From e268ff39b648e7b100d2aa50f472b4ff8ff5313a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
Date: Fri, 2 Sep 2022 21:10:05 +0200
Subject: [PATCH] gio/tests/gdbus-peer: Unref cached property GVariant value
Helps with: https://gitlab.gnome.org/GNOME/glib/-/issues/333
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/e268ff39b648e7b100d2aa50f472b4ff8ff5313a
---
gio/tests/gdbus-peer.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/gio/tests/gdbus-peer.c b/gio/tests/gdbus-peer.c
index 7179d089df..763689a4fd 100644
--- a/gio/tests/gdbus-peer.c
+++ b/gio/tests/gdbus-peer.c
@@ -843,6 +843,7 @@ do_test_peer (void)
error = NULL;
value = g_dbus_proxy_get_cached_property (proxy, "PeerProperty");
g_assert_cmpstr (g_variant_get_string (value, NULL), ==, "ThePropertyValue");
+ g_clear_pointer (&value, g_variant_unref);
/* try invoking a method */
error = NULL;
--
GitLab

View File

@ -0,0 +1,67 @@
From 1da208cddc19cad05ccf4b798a99f7045e41ffc4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
Date: Fri, 2 Sep 2022 20:26:06 +0200
Subject: [PATCH] gio/tests/gdbus-proxy-threads: Unref GVariant's that we own
This test is leaking various GVariant's that we are supposed to unref,
leading the valgrind CI job to complain about.
Helps with: https://gitlab.gnome.org/GNOME/glib/-/issues/333
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/1da208cddc19cad05ccf4b798a99f7045e41ffc4
---
gio/tests/gdbus-proxy-threads.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/gio/tests/gdbus-proxy-threads.c b/gio/tests/gdbus-proxy-threads.c
index 76b857e731..a0a38d07cd 100644
--- a/gio/tests/gdbus-proxy-threads.c
+++ b/gio/tests/gdbus-proxy-threads.c
@@ -119,13 +119,17 @@ request_name_cb (GObject *source,
GDBusConnection *connection = G_DBUS_CONNECTION (source);
GError *error = NULL;
GVariant *var;
+ GVariant *child;
var = g_dbus_connection_call_finish (connection, res, &error);
g_assert_no_error (error);
- g_assert_cmpuint (g_variant_get_uint32 (g_variant_get_child_value (var, 0)),
+ child = g_variant_get_child_value (var, 0);
+ g_assert_cmpuint (g_variant_get_uint32 (child),
==, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER);
release_name (connection, TRUE);
+ g_variant_unref (child);
+ g_variant_unref (var);
}
static void
@@ -154,11 +158,13 @@ release_name_cb (GObject *source,
GDBusConnection *connection = G_DBUS_CONNECTION (source);
GError *error = NULL;
GVariant *var;
+ GVariant *child;
int i;
var = g_dbus_connection_call_finish (connection, res, &error);
g_assert_no_error (error);
- g_assert_cmpuint (g_variant_get_uint32 (g_variant_get_child_value (var, 0)),
+ child = g_variant_get_child_value (var, 0);
+ g_assert_cmpuint (g_variant_get_uint32 (child),
==, DBUS_RELEASE_NAME_REPLY_RELEASED);
/* generate some rapid NameOwnerChanged signals to try to trigger crashes */
@@ -170,6 +176,8 @@ release_name_cb (GObject *source,
/* wait for dbus-daemon to catch up */
request_name (connection, TRUE);
+ g_variant_unref (child);
+ g_variant_unref (var);
}
static void
--
GitLab

View File

@ -0,0 +1,33 @@
From 2401e1a090dcaac7614a8984cd3e3832a2a476ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
Date: Fri, 16 Sep 2022 15:11:47 +0200
Subject: [PATCH] glocalfileoutputstream: Do not double-close an fd on unlink
error
In case we fail unlinking a file we could close again an FD that has
been already just closed. So avoid this by unsetting it when closing.
Coverity CID: #1474462
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/2401e1a090dcaac7614a8984cd3e3832a2a476ab
---
gio/glocalfileoutputstream.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gio/glocalfileoutputstream.c b/gio/glocalfileoutputstream.c
index 400934be1f..3ce987fba8 100644
--- a/gio/glocalfileoutputstream.c
+++ b/gio/glocalfileoutputstream.c
@@ -1163,6 +1163,7 @@ handle_overwrite_open (const char *filename,
if (replace_destination_set)
{
g_close (fd, NULL);
+ fd = -1;
if (g_unlink (filename) != 0)
{
--
GitLab

View File

@ -0,0 +1,119 @@
From 511627b7356af527c85c049e2020a36694d7de54 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
Date: Fri, 2 Sep 2022 18:56:35 +0200
Subject: [PATCH] tests/dbus-appinfo: Add test case for flatpak opening an
invalid file
We were testing the case in which we were opening an actual file, and so
potentially using a fd-list, however we were missing the case in which a file
was not existent.
And in such case we are incidentally hitting a leak now.
Conflict:NA
Reference:https://gitlab.gnome.org/GNOME/glib/-/commit/511627b7356af527c85c049e2020a36694d7de54
---
gio/tests/dbus-appinfo.c | 79 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
diff --git a/gio/tests/dbus-appinfo.c b/gio/tests/dbus-appinfo.c
index 2017e02df2..91e76403c6 100644
--- a/gio/tests/dbus-appinfo.c
+++ b/gio/tests/dbus-appinfo.c
@@ -360,6 +360,84 @@ test_flatpak_doc_export (void)
g_object_unref (flatpak_appinfo);
}
+static void
+on_flatpak_launch_invalid_uri_finish (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GApplication *app = user_data;
+ GError *error = NULL;
+
+ g_app_info_launch_uris_finish (G_APP_INFO (object), result, &error);
+ g_assert_no_error (error);
+
+ g_application_release (app);
+}
+
+static void
+on_flatpak_activate_invalid_uri (GApplication *app,
+ gpointer user_data)
+{
+ GDesktopAppInfo *flatpak_appinfo = user_data;
+ GList *uris;
+
+ /* The app will be released in on_flatpak_launch_uris_finish */
+ g_application_hold (app);
+
+ uris = g_list_prepend (NULL, "file:///hopefully/an/invalid/path.desktop");
+ g_app_info_launch_uris_async (G_APP_INFO (flatpak_appinfo), uris, NULL,
+ NULL, on_flatpak_launch_invalid_uri_finish, app);
+ g_list_free (uris);
+}
+
+static void
+on_flatpak_open_invalid_uri (GApplication *app,
+ GFile **files,
+ gint n_files,
+ const char *hint)
+{
+ GFile *f;
+
+ g_assert_cmpint (n_files, ==, 1);
+ g_test_message ("on_flatpak_open received file '%s'", g_file_peek_path (files[0]));
+
+ /* The file has been exported via the document portal */
+ f = g_file_new_for_uri ("file:///hopefully/an/invalid/path.desktop");
+ g_assert_true (g_file_equal (files[0], f));
+ g_object_unref (f);
+}
+
+static void
+test_flatpak_missing_doc_export (void)
+{
+ const gchar *argv[] = { "myapp", NULL };
+ gchar *desktop_file = NULL;
+ GDesktopAppInfo *flatpak_appinfo;
+ GApplication *app;
+ int status;
+
+ g_test_summary ("Test that files launched via Flatpak apps are made available via the document portal.");
+
+ desktop_file = g_test_build_filename (G_TEST_DIST,
+ "org.gtk.test.dbusappinfo.flatpak.desktop",
+ NULL);
+ flatpak_appinfo = g_desktop_app_info_new_from_filename (desktop_file);
+ g_assert_nonnull (flatpak_appinfo);
+
+ app = g_application_new ("org.gtk.test.dbusappinfo.flatpak",
+ G_APPLICATION_HANDLES_OPEN);
+ g_signal_connect (app, "activate", G_CALLBACK (on_flatpak_activate_invalid_uri),
+ flatpak_appinfo);
+ g_signal_connect (app, "open", G_CALLBACK (on_flatpak_open_invalid_uri), NULL);
+
+ status = g_application_run (app, 1, (gchar **) argv);
+ g_assert_cmpint (status, ==, 0);
+
+ g_object_unref (app);
+ g_object_unref (flatpak_appinfo);
+ g_free (desktop_file);
+}
+
int
main (int argc, char **argv)
{
@@ -367,6 +445,7 @@ main (int argc, char **argv)
g_test_add_func ("/appinfo/dbusappinfo", test_dbus_appinfo);
g_test_add_func ("/appinfo/flatpak-doc-export", test_flatpak_doc_export);
+ g_test_add_func ("/appinfo/flatpak-missing-doc-export", test_flatpak_missing_doc_export);
return session_bus_run ();
}
--
GitLab

View File

@ -1,6 +1,6 @@
Name: glib2
Version: 2.66.8
Release: 8
Release: 9
Summary: The core library that forms the basis for projects such as GTK+ and GNOME
License: LGPLv2+
URL: http://www.gtk.org
@ -57,6 +57,13 @@ Patch6046: backport-gunixmounts-Add-cache-to-g_unix_mount_points_get.patch
Patch6047: backport-Add-lock-in-_g_get_unix_mount_points-around-fsent-functions.patch
Patch6048: backport-g_get_unix_mount_points-reduce-syscalls-inside-loop.patch
Patch6049: backport-tests-Make-the-642026-test-take-100x-less-time.patch
Patch6050: backport-tests-dbus-appinfo-Add-test-case-for-flatpak-opening-an-invalid-file.patch
Patch6051: backport-documentportal-Fix-small-leak-in-add_documents-with-empty-URI-list.patch
Patch6052: backport-gio-tests-gdbus-proxy-threads-Unref-GVariant-s-that-we-own.patch
Patch6053: backport-gio-tests-gdbus-peer-Unref-cached-property-GVariant-value.patch
Patch6054: backport-gdesktopappinfo-Unref-the-GDBus-call-results.patch
Patch6055: backport-Handling-collision-between-standard-i-o-file-descriptors-and-newly-created-ones.patch
Patch6056: backport-glocalfileoutputstream-Do-not-double-close-an-fd-on-unlink-error.patch
BuildRequires: chrpath gcc gcc-c++ gettext perl-interpreter
%ifnarch i686
@ -229,6 +236,9 @@ glib-compile-schemas %{_datadir}/glib-2.0/schemas &> /dev/null || :
%endif
%changelog
* Mon Dec 26 2022 hanhuihui <hanhuihui5@huawei.com> - 2.66.8-9
- backport some patches from community
* Wed Dec 14 2022 hanhuihui <hanhuihui5@huawei.com> - 2.66.8-8
- fix failed tests