summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Bell <richard.s.bell@intel.com>2015-05-01 15:16:26 -0700
committerRick Bell <richard.s.bell@intel.com>2015-05-01 15:16:26 -0700
commitb7514080bbcd88724c8609a56c46ed97c1ae66e4 (patch)
tree554d3dcf4da357399c7744b212de975b52110ff0
parent54a0f4fa30f73b23d890b4fdc3d4cb67ae9e13e9 (diff)
downloaddleyna-renderer-b7514080bbcd88724c8609a56c46ed97c1ae66e4.tar.gz
Used core functionality dleyna_core_prv_convert_udn_to_path for persistent path
-rw-r--r--libdleyna/renderer/device.c51
1 files changed, 3 insertions, 48 deletions
diff --git a/libdleyna/renderer/device.c b/libdleyna/renderer/device.c
index 64b5770..783fb52 100644
--- a/libdleyna/renderer/device.c
+++ b/libdleyna/renderer/device.c
@@ -1,7 +1,7 @@
/*
* dLeyna
*
- * Copyright (C) 2012-2013 Intel Corporation. All rights reserved.
+ * Copyright (C) 2012-2015 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -28,6 +28,7 @@
#include <libgupnp/gupnp-control-point.h>
#include <libgupnp-av/gupnp-av.h>
+#include <libdleyna/core/core.h>
#include <libdleyna/core/error.h>
#include <libdleyna/core/log.h>
#include <libdleyna/core/service-task.h>
@@ -827,52 +828,6 @@ void dlr_device_construct(
DLEYNA_LOG_DEBUG("Exit");
}
-static char *prv_convert_udn_to_path(const char *udn)
-{
- char *uuid;
- size_t len;
- size_t dest_len;
- size_t i;
-
- /* This function will generate a valid dbus path from the udn
- * We are not going to check the UDN validity. We will try to
- * convert it anyway. To avoid any security problem, we will
- * check some limits and possibily return only a partial
- * UDN. For a better understanding, a valid UDN should be:
- * UDN = "uuid:4Hex-2Hex-2Hex-Hex-Hex-6Hex"
- *
- * The convertion rules are:
- * 1 - An invalid char will be escaped using its hexa representation
- * prefixed with '_': Ex ':' -> '_3A'
- * 2 - The max size of the converted UDN can be 3 times the original
- * size (if all char are not dbus compliant).
- * The max size of a dbus path is an UINT32: G_MAXUINT32
- * We will limit the of the converted string size to G_MAXUINT32 / 2
- * otherwise we will never have space to generate object path.
- */
-
- len = strlen(udn);
- dest_len = MIN(len * 3, G_MAXUINT32 / 2);
-
- uuid = g_malloc(dest_len + 1);
- i = 0;
-
- while (*udn && (i < dest_len))
- {
- if (g_ascii_isalnum(*udn) || (*udn == '_'))
- uuid[i++] = *udn;
- else
- i += g_snprintf(uuid + i, dest_len + 1,"_%02x", *udn);
-
- udn++;
- }
-
-
- uuid[i]=0;
-
- return uuid;
-}
-
dlr_device_t *dlr_device_new(
dleyna_connector_id_t connection,
GUPnPDeviceProxy *proxy,
@@ -888,7 +843,7 @@ dlr_device_t *dlr_device_new(
DLEYNA_LOG_DEBUG("New Device on %s", ip_address);
- uuid = prv_convert_udn_to_path(udn);
+ uuid = dleyna_core_prv_convert_udn_to_path(udn);
new_path = g_strdup_printf("%s/%s", DLEYNA_SERVER_PATH, uuid);
g_free(uuid);