Port to gupnp-1.2 and fix bug.

This commit is contained in:
wenlong ding 2021-06-23 13:32:51 +08:00
parent 0272216861
commit 329e7867bf
3 changed files with 144 additions and 3 deletions

View File

@ -0,0 +1,66 @@
From 3f62e9fbd3de11df52184ca8dfcabfb7d1c0fdeb Mon Sep 17 00:00:00 2001
From: Robert Tiemann <rtie@gmx.de>
Date: Fri, 17 May 2019 12:43:04 +0200
Subject: [PATCH] Avoid possible crash when getting server properties.
The crash occurs when calling dls_device_get_all_props() for a content
directory server that we have not yet subscribed to (that is,
prv_cds_subscribed() returns FALSE in
prv_get_system_update_id_for_props()). This crash is caused by an
invalid GVariantBuilder passed to g_variant_builder_end() in
prv_get_sleeping_for_props(), leading to a NULL result pointer being
passed to dls_async_task_complete(). A GVariant is attempted to be
constructed from this NULL pointer in dls_task_complete().
Here is the call chain that leads to the crash:
dls_device_get_all_props()
prv_get_system_update_id_for_props()
gupnp_service_proxy_begin_action("GetSystemUpdateID") -> prv_system_update_id_for_props_cb()
prv_system_update_id_for_props_cb()
prv_get_sr_token_for_props()
prv_get_sleeping_for_props()
dls_async_task_complete()
cb_data->cb() -> prv_async_task_complete()
prv_async_task_complete()
dls_task_complete()
g_variant_new()
The crash was most likely observed when a device running Plex Media
Server was present on the network.
This commit moves the call of g_variant_builder_end() in
prv_system_update_id_for_props_cb() (which invalidates the
GVariantBuilder used later in prv_get_sleeping_for_props()) to the
error handling branch. This leaves the GVariantBuilder alone and
allows prv_get_sr_token_for_props() or one of its descendants to call
g_variant_builder_end() and complete the task.
---
libdleyna/server/device.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/libdleyna/server/device.c b/libdleyna/server/device.c
index d77dfbc2725b..8777da0ea2db 100644
--- a/libdleyna/server/device.c
+++ b/libdleyna/server/device.c
@@ -2256,15 +2256,14 @@ static void prv_system_update_id_for_props_cb(GUPnPServiceProxy *proxy,
DLS_SYSTEM_UPDATE_VAR,
g_variant_new_uint32(id));
- cb_data->task.result = g_variant_ref_sink(g_variant_builder_end(
- cb_task_data->vb));
-
on_complete:
if (!cb_data->error)
prv_get_sr_token_for_props(proxy, cb_data->task.target.device,
cb_data);
else {
+ cb_data->task.result = g_variant_ref_sink(g_variant_builder_end(
+ cb_task_data->vb));
(void) g_idle_add(dls_async_task_complete, cb_data);
g_cancellable_disconnect(cb_data->cancellable,
cb_data->cancel_id);
--
2.28.0

View File

@ -2,15 +2,18 @@
Name: dleyna-server
Version: 0.6.0
Release: 4
Release: 5
Summary: APIs for discovering Digital Media Servers
License: LGPLv2
URL: https://01.org/dleyna/
Source0: https://01.org/sites/default/files/downloads/dleyna/dleyna-server-%{version}.tar_2.gz
Patch0: port-to-gupnp-1.2.patch
Patch1: dleyna-server-Avoid-possible-crash-when-getting-server-properties.patch
BuildRequires: autoconf automake libtool pkgconfig(dleyna-core-1.0) >= 0.5.0
BuildRequires: pkgconfig(gio-2.0) >= 2.28 pkgconfig(glib-2.0) >= 2.28
BuildRequires: pkgconfig(gobject-2.0) >= 2.28 pkgconfig(gssdp-1.0) >= 0.13.2
BuildRequires: pkgconfig(gupnp-1.0) >= 0.20.3 pkgconfig(gupnp-av-1.0) >= 0.11.5
BuildRequires: pkgconfig(gobject-2.0) >= 2.28 pkgconfig(gssdp-1.2) >= 0.13.2
BuildRequires: pkgconfig(gupnp-1.2) >= 0.20.3 pkgconfig(gupnp-av-1.0) >= 0.11.5
BuildRequires: pkgconfig(gupnp-dlna-2.0) >= 0.9.4 pkgconfig(libsoup-2.4) >= 2.28.2
Requires: dbus dleyna-connector-dbus
@ -40,5 +43,9 @@ sed --in-place --expression 's! -shared ! -Wl,--as-needed\0!g' libtool
%exclude %{_libdir}/pkgconfig
%changelog
* Wed Jun 23 2021 Wenlong Ding <wenlong.ding@turbolinux.com.cn> - 0.6.0-5
- Port to gupnp 1.2
- Avoid crash when getting server properties
* Thu Apr 16 2020 chengzihan <chengzihan2@huawei.com> - 0.6.0-4
- Package init

68
port-to-gupnp-1.2.patch Normal file
View File

@ -0,0 +1,68 @@
From 96c01c88363d6e5e9b7519bc4e8b5d86cf783e1f Mon Sep 17 00:00:00 2001
From: Jan Tojnar <jtojnar@gmail.com>
Date: Sat, 16 Mar 2019 05:46:20 +0100
Subject: [PATCH] Port to gupnp-1.2
gupnp_context_get_host_ip has been deprecated for a long time, as
the host-ip property moved to gssdp.
There is also a ton of new deprecations but I will address that separately.
---
configure.ac | 8 ++++----
libdleyna/server/upnp.c | 4 ++--
test/dbus/dms-info.c | 2 --
3 files changed, 6 insertions(+), 8 deletions(-)
mode change 100755 => 100644 libdleyna/server/upnp.c
mode change 100755 => 100644 test/dbus/dms-info.c
diff --git a/configure.ac b/configure.ac
index 11879e7..61f4fca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,10 +36,10 @@ LT_LANG([C])
# Checks for libraries.
PKG_PROG_PKG_CONFIG(0.16)
-PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.28])
-PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.28])
-PKG_CHECK_MODULES([GSSDP], [gssdp-1.0 >= 0.13.2])
-PKG_CHECK_MODULES([GUPNP], [gupnp-1.0 >= 0.20.3])
+PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.36])
+PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.36])
+PKG_CHECK_MODULES([GSSDP], [gssdp-1.2 >= 0.13.2])
+PKG_CHECK_MODULES([GUPNP], [gupnp-1.2 >= 0.20.3])
PKG_CHECK_MODULES([GUPNPAV], [gupnp-av-1.0 >= 0.11.5])
PKG_CHECK_MODULES([GUPNPDLNA], [gupnp-dlna-2.0 >= 0.9.4])
PKG_CHECK_MODULES([SOUP], [libsoup-2.4 >= 2.28.2])
diff --git a/libdleyna/server/upnp.c b/libdleyna/server/upnp.c
old mode 100755
new mode 100644
index 9913a76..d04efb8
--- a/libdleyna/server/upnp.c
+++ b/libdleyna/server/upnp.c
@@ -351,8 +351,8 @@ static void prv_device_unavailable_cb(GUPnPControlPoint *cp,
udn = gupnp_device_info_get_udn((GUPnPDeviceInfo *)proxy);
- ip_address = gupnp_context_get_host_ip(
- gupnp_control_point_get_context(cp));
+ ip_address = gssdp_client_get_host_ip(
+ GSSDP_CLIENT(gupnp_control_point_get_context(cp)));
if (!udn || !ip_address)
goto on_error;
diff --git a/test/dbus/dms-info.c b/test/dbus/dms-info.c
old mode 100755
new mode 100644
index a189b9f..4530e58
--- a/test/dbus/dms-info.c
+++ b/test/dbus/dms-info.c
@@ -360,8 +360,6 @@ int main(int argc, char *argv[])
if (sigprocmask(SIG_BLOCK, &mask, NULL) == -1)
goto on_error;
- g_type_init();
-
/* Create proxy for com.intel.dLeynaServer.Manager. The Manager
object has no properties. We will create the proxy asynchronously
and use G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES to ensure that