From 58567d73b5d2d6af11a24ac79a8f4f8a9028864c73e33f51d2a9ec1995b016fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Lie?= Date: Mon, 29 Aug 2022 06:39:49 +0000 Subject: [PATCH] Accepting request 999241 from home:iznogood - Add 99783e0408f8ae9628d2c7a30eb99806087da711.patch: gsocketclient: Fix passing NULL to g_task_get_cancellable(). Fix a regression from commit abddb42d14, where it could pass `NULL` to `g_task_get_cancellable()`, triggering a critical warning. This could happen because the lifetime of `data->task` is not as long as the lifetime of the `ConnectionAttempt`, but the code assumed it was. Fix the problem by keeping a strong ref to that `GCancellable` around until the `ConnectionAttempt` is finished being destroyed. OBS-URL: https://build.opensuse.org/request/show/999241 OBS-URL: https://build.opensuse.org/package/show/GNOME:Factory/glib2?expand=0&rev=486 --- ...3e0408f8ae9628d2c7a30eb99806087da711.patch | 61 +++++++++++++++++++ glib2.changes | 13 ++++ glib2.spec | 3 + 3 files changed, 77 insertions(+) create mode 100644 99783e0408f8ae9628d2c7a30eb99806087da711.patch diff --git a/99783e0408f8ae9628d2c7a30eb99806087da711.patch b/99783e0408f8ae9628d2c7a30eb99806087da711.patch new file mode 100644 index 0000000..804e5ca --- /dev/null +++ b/99783e0408f8ae9628d2c7a30eb99806087da711.patch @@ -0,0 +1,61 @@ +From 99783e0408f8ae9628d2c7a30eb99806087da711 Mon Sep 17 00:00:00 2001 +From: Philip Withnall +Date: Tue, 12 Jul 2022 16:07:23 +0100 +Subject: [PATCH] gsocketclient: Fix passing NULL to g_task_get_cancellable() + +Fix a regression from commit abddb42d14, where it could pass `NULL` to +`g_task_get_cancellable()`, triggering a critical warning. This could +happen because the lifetime of `data->task` is not as long as the +lifetime of the `ConnectionAttempt`, but the code assumed it was. + +Fix the problem by keeping a strong ref to that `GCancellable` around +until the `ConnectionAttempt` is finished being destroyed. + +Signed-off-by: Philip Withnall + +Fixes: #2687 +--- + gio/gsocketclient.c | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +diff --git a/gio/gsocketclient.c b/gio/gsocketclient.c +index cd5aa074a1..8bcbdfa85d 100644 +--- a/gio/gsocketclient.c ++++ b/gio/gsocketclient.c +@@ -1508,6 +1508,7 @@ typedef struct + GSocketClientAsyncConnectData *data; /* unowned */ + GSource *timeout_source; + GCancellable *cancellable; ++ GCancellable *task_cancellable; /* (owned); this is equal to g_task_get_cancellable (ConnectionAttempt.data->task), but with a longer lifetime */ + gulong cancelled_id; + grefcount ref; + } ConnectionAttempt; +@@ -1536,7 +1537,8 @@ connection_attempt_unref (gpointer pointer) + g_clear_object (&attempt->address); + g_clear_object (&attempt->socket); + g_clear_object (&attempt->connection); +- g_cancellable_disconnect (g_task_get_cancellable (attempt->data->task), attempt->cancelled_id); ++ g_cancellable_disconnect (attempt->task_cancellable, attempt->cancelled_id); ++ g_clear_object (&attempt->task_cancellable); + attempt->cancelled_id = 0; + g_clear_object (&attempt->cancellable); + g_clear_object (&attempt->proxy_addr); +@@ -2031,9 +2033,12 @@ g_socket_client_enumerator_callback (GObject *object, + data->connection_attempts = g_slist_append (data->connection_attempts, attempt); + + if (g_task_get_cancellable (data->task)) +- attempt->cancelled_id = +- g_cancellable_connect (g_task_get_cancellable (data->task), G_CALLBACK (on_connection_cancelled), +- g_object_ref (attempt->cancellable), g_object_unref); ++ { ++ attempt->task_cancellable = g_object_ref (g_task_get_cancellable (data->task)); ++ attempt->cancelled_id = ++ g_cancellable_connect (attempt->task_cancellable, G_CALLBACK (on_connection_cancelled), ++ g_object_ref (attempt->cancellable), g_object_unref); ++ } + + g_socket_connection_set_cached_remote_address ((GSocketConnection *)attempt->connection, address); + g_debug ("GSocketClient: Starting TCP connection attempt"); +-- +GitLab + diff --git a/glib2.changes b/glib2.changes index 8ca8931..ce3e297 100644 --- a/glib2.changes +++ b/glib2.changes @@ -1,3 +1,16 @@ +------------------------------------------------------------------- +Thu Aug 25 11:24:35 UTC 2022 - Bjørn Lie + +- Add 99783e0408f8ae9628d2c7a30eb99806087da711.patch: + gsocketclient: Fix passing NULL to g_task_get_cancellable(). + Fix a regression from commit abddb42d14, where it could pass + `NULL` to `g_task_get_cancellable()`, triggering a critical + warning. This could happen because the lifetime of `data->task` + is not as long as the lifetime of the `ConnectionAttempt`, but + the code assumed it was. + Fix the problem by keeping a strong ref to that `GCancellable` + around until the `ConnectionAttempt` is finished being destroyed. + ------------------------------------------------------------------- Sun Jul 3 23:43:59 UTC 2022 - Emily Gonyer diff --git a/glib2.spec b/glib2.spec index 3df0a55..c1d4dec 100644 --- a/glib2.spec +++ b/glib2.spec @@ -58,6 +58,8 @@ Patch2: glib2-suppress-schema-deprecated-path-warning.patch Patch3: glib2-dbus-socket-path.patch # PATCH-FIX-OPENSUSE glib2-gdbus-codegen-version.patch olaf@aepfle.de -- Remove version string from files generated by gdbus-codegen Patch4: glib2-gdbus-codegen-version.patch +# PATCH-FIX-UPSTREAM commit/99783e0408f8ae9628d2c7a30eb99806087da711.patch -- gsocketclient: Fix passing NULL to g_task_get_cancellable() +Patch5: https://gitlab.gnome.org/GNOME/glib/-/commit/99783e0408f8ae9628d2c7a30eb99806087da711.patch BuildRequires: docbook-xsl-stylesheets BuildRequires: fdupes BuildRequires: gcc-c++ @@ -260,6 +262,7 @@ the functionality of the installed glib2 package. %patch2 -p1 %patch3 -p1 %patch4 -p1 +%patch5 -p1 cp -a %{SOURCE1} %{SOURCE2} %{SOURCE5} . cp -a %{SOURCE4} gnome_defaults.conf # replace /usr/bin/env shebangs