|
|
778716 |
From cd5f5fcbde1dd92dabc59058ad90cf0e7dcfaad9 Mon Sep 17 00:00:00 2001
|
|
|
778716 |
From: Colin Walters <walters@verbum.org>
|
|
|
778716 |
Date: Mon, 3 Apr 2017 12:46:37 -0400
|
|
|
778716 |
Subject: [PATCH] soup: Hold a ref to the pending URI during completion
|
|
|
778716 |
processing
|
|
|
778716 |
|
|
|
778716 |
It was reported that in the range request handling, we called `remove_pending()`
|
|
|
778716 |
twice, and this could be viewed as a use-after-free. Currently though, the task
|
|
|
778716 |
object already holds a strong reference, so I observed the refcount was 2, hence
|
|
|
778716 |
there is no use-after-free in practice.
|
|
|
778716 |
|
|
|
778716 |
Reported-By: "Siddharth Sharma" <siddharth@redhat.com>
|
|
|
778716 |
---
|
|
|
778716 |
src/libostree/ostree-fetcher-soup.c | 12 ++++++------
|
|
|
778716 |
1 file changed, 6 insertions(+), 6 deletions(-)
|
|
|
778716 |
|
|
|
778716 |
diff --git a/src/libostree/ostree-fetcher-soup.c b/src/libostree/ostree-fetcher-soup.c
|
|
|
778716 |
index b130b48..0a931c4 100644
|
|
|
778716 |
--- a/src/libostree/ostree-fetcher-soup.c
|
|
|
778716 |
+++ b/src/libostree/ostree-fetcher-soup.c
|
|
|
778716 |
@@ -1040,21 +1040,20 @@ on_request_sent (GObject *object,
|
|
|
778716 |
gpointer user_data)
|
|
|
778716 |
{
|
|
|
778716 |
GTask *task = G_TASK (user_data);
|
|
|
778716 |
- OstreeFetcherPendingURI *pending;
|
|
|
778716 |
- GCancellable *cancellable;
|
|
|
778716 |
+ /* Hold a ref to the pending across this function, since we remove
|
|
|
778716 |
+ * it from the hash early in some cases, not in others. */
|
|
|
778716 |
+ OstreeFetcherPendingURI *pending = pending_uri_ref (g_task_get_task_data (task));
|
|
|
778716 |
+ GCancellable *cancellable = g_task_get_cancellable (task);
|
|
|
778716 |
GError *local_error = NULL;
|
|
|
778716 |
glnx_unref_object SoupMessage *msg = NULL;
|
|
|
778716 |
|
|
|
778716 |
- pending = g_task_get_task_data (task);
|
|
|
778716 |
- cancellable = g_task_get_cancellable (task);
|
|
|
778716 |
-
|
|
|
778716 |
pending->state = OSTREE_FETCHER_STATE_COMPLETE;
|
|
|
778716 |
pending->request_body = soup_request_send_finish ((SoupRequest*) object,
|
|
|
778716 |
result, &local_error);
|
|
|
778716 |
|
|
|
778716 |
if (!pending->request_body)
|
|
|
778716 |
goto out;
|
|
|
778716 |
-
|
|
|
778716 |
+
|
|
|
778716 |
if (SOUP_IS_REQUEST_HTTP (object))
|
|
|
778716 |
{
|
|
|
778716 |
msg = soup_request_http_get_message ((SoupRequestHTTP*) object);
|
|
|
778716 |
@@ -1183,6 +1182,7 @@ on_request_sent (GObject *object,
|
|
|
778716 |
remove_pending (pending);
|
|
|
778716 |
}
|
|
|
778716 |
|
|
|
778716 |
+ pending_uri_unref (pending);
|
|
|
778716 |
g_object_unref (task);
|
|
|
778716 |
}
|
|
|
778716 |
|
|
|
778716 |
--
|
|
|
778716 |
2.9.3
|
|
|
778716 |
|