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

53 lines
1.7 KiB
Diff
Raw Normal View History

2024-10-04 11:31:35 +00:00
From 873e49357081e5c5d8d3d23759f1723db7292bf6 Mon Sep 17 00:00:00 2001
2021-11-04 01:52:40 +00:00
From: Bastien Nocera <hadess@hadess.net>
2024-10-04 11:31:35 +00:00
Date: Mon, 12 Feb 2024 20:02:45 +0000
Subject: [PATCH] obex: Use GLib helper function to manipulate paths
2021-11-04 01:52:40 +00:00
Instead of trying to do it by hand. This also makes sure that
relative paths aren't used by the agent.
2024-10-04 11:31:35 +00:00
[Emil Velikov]
Originally this patch was posted in 2013, but deferred since bluez was
planning to move away from glib. Presently there's no obvious action
towards that goal, so I think we can safely land this.
As mentioned by the author, current code allows for relative paths and
considering that obexd service runs without meaningful sandboxing and on
some distributions it is ran as root, we should plug the whole before
anyone (ab)uses it.
2021-11-04 01:52:40 +00:00
---
2024-10-04 11:31:35 +00:00
obexd/src/manager.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
2021-11-04 01:52:40 +00:00
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
2024-10-04 11:31:35 +00:00
index 73fd6b9aff15..cc1de7ae2ed3 100644
2021-11-04 01:52:40 +00:00
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
2024-10-04 11:31:35 +00:00
@@ -644,18 +644,13 @@ static void agent_reply(DBusPendingCall *call, void *user_data)
2021-11-04 01:52:40 +00:00
DBUS_TYPE_STRING, &name,
DBUS_TYPE_INVALID)) {
/* Splits folder and name */
- const char *slash = strrchr(name, '/');
+ gboolean is_relative = !g_path_is_absolute(name);
DBG("Agent replied with %s", name);
- if (!slash) {
- agent->new_name = g_strdup(name);
2024-10-04 11:31:35 +00:00
+ agent->new_name = g_path_get_basename(name);
+ if (is_relative)
2021-11-04 01:52:40 +00:00
agent->new_folder = NULL;
2024-10-04 11:31:35 +00:00
- } else {
- if (strlen(slash) == 1)
- agent->new_name = NULL;
- else
- agent->new_name = g_strdup(slash + 1);
2021-11-04 01:52:40 +00:00
- agent->new_folder = g_strndup(name, slash - name);
2024-10-04 11:31:35 +00:00
- }
+ else
2021-11-04 01:52:40 +00:00
+ agent->new_folder = g_path_get_dirname(name);
}
2024-10-04 11:31:35 +00:00
dbus_message_unref(reply);
2021-11-04 01:52:40 +00:00
--
2024-10-04 11:31:35 +00:00
2.43.0
2021-11-04 01:52:40 +00:00