Blame SOURCES/0001-Fix-possible-use-after-free-on-exit.patch

19d688
From 2a09e2b15e7493256de4f40331ce6be4e1fe90f4 Mon Sep 17 00:00:00 2001
19d688
From: Bastien Nocera <hadess@hadess.net>
19d688
Date: Thu, 3 Dec 2015 18:28:46 +0100
19d688
Subject: [PATCH] Fix possible use-after-free on exit
19d688
19d688
When the last client of dleyna-server exits, and dleyna-server
19d688
tries to exit, it might use the "upnp" pointer after it was freed as we
19d688
receive a signal where the user_data is invalid. Avoid that by zero'ing
19d688
freed pointers and disconnecting from the signal for which "upnp" is
19d688
user_data.
19d688
19d688
See https://retrace.fedoraproject.org/faf/reports/855440/
19d688
---
19d688
 libdleyna/server/server.c | 5 ++++-
19d688
 libdleyna/server/upnp.c   | 3 +++
19d688
 2 files changed, 7 insertions(+), 1 deletion(-)
19d688
19d688
diff --git a/libdleyna/server/server.c b/libdleyna/server/server.c
19d688
index ec725de3f6b3..865336162d61 100644
19d688
--- a/libdleyna/server/server.c
19d688
+++ b/libdleyna/server/server.c
19d688
@@ -1352,12 +1352,15 @@ static void prv_control_point_stop_service(void)
19d688
 {
19d688
 	uint i;
19d688
 
19d688
-	if (g_context.manager)
19d688
+	if (g_context.manager) {
19d688
 		dls_manager_delete(g_context.manager);
19d688
+		g_context.manager = NULL;
19d688
+	}
19d688
 
19d688
 	if (g_context.upnp) {
19d688
 		dls_upnp_unsubscribe(g_context.upnp);
19d688
 		dls_upnp_delete(g_context.upnp);
19d688
+		g_context.upnp = NULL;
19d688
 	}
19d688
 
19d688
 	if (g_context.connection) {
19d688
diff --git a/libdleyna/server/upnp.c b/libdleyna/server/upnp.c
19d688
index 6d6c696dd42c..dcf31d98f171 100755
19d688
--- a/libdleyna/server/upnp.c
19d688
+++ b/libdleyna/server/upnp.c
19d688
@@ -547,6 +547,9 @@ dls_upnp_t *dls_upnp_new(dleyna_connector_id_t connection,
19d688
 void dls_upnp_delete(dls_upnp_t *upnp)
19d688
 {
19d688
 	if (upnp) {
19d688
+		g_signal_handlers_disconnect_by_func (G_OBJECT (upnp->context_manager),
19d688
+						      G_CALLBACK(prv_on_context_available),
19d688
+						      upnp);
19d688
 		g_object_unref(upnp->context_manager);
19d688
 		g_hash_table_unref(upnp->property_map);
19d688
 		g_hash_table_unref(upnp->filter_map);
19d688
-- 
19d688
2.5.5
19d688