Blame SOURCES/0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch

ab4cc4
From 90b72b787a6ae6b9b0bf8ece238e108e8607a433 Mon Sep 17 00:00:00 2001
ab4cc4
From: Bastien Nocera <hadess@hadess.net>
ab4cc4
Date: Sat, 9 Nov 2013 18:13:43 +0100
ab4cc4
Subject: [PATCH 1/2] obex: Use GLib helper function to manipulate paths
ab4cc4
ab4cc4
Instead of trying to do it by hand. This also makes sure that
ab4cc4
relative paths aren't used by the agent.
ab4cc4
---
ab4cc4
 obexd/src/manager.c | 10 +++++-----
ab4cc4
 1 file changed, 5 insertions(+), 5 deletions(-)
ab4cc4
ab4cc4
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
ab4cc4
index f84384ae4..285c07c37 100644
ab4cc4
--- a/obexd/src/manager.c
ab4cc4
+++ b/obexd/src/manager.c
ab4cc4
@@ -650,14 +650,14 @@ static void agent_reply(DBusPendingCall *call, void *user_data)
ab4cc4
 				DBUS_TYPE_STRING, &name,
ab4cc4
 				DBUS_TYPE_INVALID)) {
ab4cc4
 		/* Splits folder and name */
ab4cc4
-		const char *slash = strrchr(name, '/');
ab4cc4
+		gboolean is_relative = !g_path_is_absolute(name);
ab4cc4
 		DBG("Agent replied with %s", name);
ab4cc4
-		if (!slash) {
ab4cc4
-			agent->new_name = g_strdup(name);
ab4cc4
+		if (is_relative) {
ab4cc4
+			agent->new_name = g_path_get_basename(name);
ab4cc4
 			agent->new_folder = NULL;
ab4cc4
 		} else {
ab4cc4
-			agent->new_name = g_strdup(slash + 1);
ab4cc4
-			agent->new_folder = g_strndup(name, slash - name);
ab4cc4
+			agent->new_name = g_path_get_basename(name);
ab4cc4
+			agent->new_folder = g_path_get_dirname(name);
ab4cc4
 		}
ab4cc4
 	}
ab4cc4
 
ab4cc4
-- 
ab4cc4
2.14.1
ab4cc4