]> git.pld-linux.org Git - packages/bluez.git/blame - 0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
up to 5.72
[packages/bluez.git] / 0001-obex-Use-GLib-helper-function-to-manipulate-paths.patch
CommitLineData
477801c9
JR
1From 90b72b787a6ae6b9b0bf8ece238e108e8607a433 Mon Sep 17 00:00:00 2001
2From: Bastien Nocera <hadess@hadess.net>
3Date: Sat, 9 Nov 2013 18:13:43 +0100
4Subject: [PATCH 1/2] obex: Use GLib helper function to manipulate paths
5
6Instead of trying to do it by hand. This also makes sure that
7relative paths aren't used by the agent.
8---
9 obexd/src/manager.c | 10 +++++-----
10 1 file changed, 5 insertions(+), 5 deletions(-)
11
12diff --git a/obexd/src/manager.c b/obexd/src/manager.c
13index f84384ae4..285c07c37 100644
14--- a/obexd/src/manager.c
15+++ b/obexd/src/manager.c
7e96ad71 16@@ -645,16 +645,19 @@
477801c9
JR
17 DBUS_TYPE_INVALID)) {
18 /* Splits folder and name */
7e96ad71 19 const char *slash = strrchr(name, '/');
477801c9
JR
20+ gboolean is_relative = !g_path_is_absolute(name);
21 DBG("Agent replied with %s", name);
22- if (!slash) {
23- agent->new_name = g_strdup(name);
24+ if (is_relative) {
25+ agent->new_name = g_path_get_basename(name);
26 agent->new_folder = NULL;
27 } else {
7e96ad71
JP
28- if (strlen(slash) == 1)
29+ if (slash && strlen(slash) == 1) {
30 agent->new_name = NULL;
31- else
32- agent->new_name = g_strdup(slash + 1);
477801c9 33- agent->new_folder = g_strndup(name, slash - name);
7e96ad71
JP
34+ agent->new_folder = g_strndup(name, slash - name);
35+ } else {
36+ agent->new_name = g_path_get_basename(name);
37+ agent->new_folder = g_path_get_dirname(name);
38+ }
477801c9
JR
39 }
40 }
41
This page took 0.16117 seconds and 4 git commands to generate.