All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] obex: Use GLib helper function to manipulate paths
@ 2013-11-09 17:18 Bastien Nocera
  2017-11-24 14:12 ` Bastien Nocera
  0 siblings, 1 reply; 4+ messages in thread
From: Bastien Nocera @ 2013-11-09 17:18 UTC (permalink / raw)
  To: linux-bluetooth


Instead of trying to do it by hand. This also makes sure that
relative paths aren't used by the agent.
---
 obexd/src/manager.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index cec8a39..f18896e 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -651,14 +651,14 @@ static void agent_reply(DBusPendingCall *call, void *user_data)
 				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);
+		if (is_relative) {
+			agent->new_name = g_path_get_basename(name);
 			agent->new_folder = NULL;
 		} else {
-			agent->new_name = g_strdup(slash + 1);
-			agent->new_folder = g_strndup(name, slash - name);
+			agent->new_name = g_path_get_basename(name);
+			agent->new_folder = g_path_get_dirname(name);
 		}
 	}
 
-- 
1.8.4.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] obex: Use GLib helper function to manipulate paths
  2013-11-09 17:18 [PATCH] obex: Use GLib helper function to manipulate paths Bastien Nocera
@ 2017-11-24 14:12 ` Bastien Nocera
  2017-11-24 15:12   ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 4+ messages in thread
From: Bastien Nocera @ 2017-11-24 14:12 UTC (permalink / raw)
  To: linux-bluetooth

On Sat, 2013-11-09 at 18:18 +0100, Bastien Nocera wrote:
> Instead of trying to do it by hand. This also makes sure that
> relative paths aren't used by the agent.

This is still relevant and applicable.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] obex: Use GLib helper function to manipulate paths
  2017-11-24 14:12 ` Bastien Nocera
@ 2017-11-24 15:12   ` Luiz Augusto von Dentz
  2017-11-24 15:18     ` Bastien Nocera
  0 siblings, 1 reply; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2017-11-24 15:12 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-bluetooth

Hi Bastien,

On Fri, Nov 24, 2017 at 4:12 PM, Bastien Nocera <hadess@hadess.net> wrote:
> On Sat, 2013-11-09 at 18:18 +0100, Bastien Nocera wrote:
>> Instead of trying to do it by hand. This also makes sure that
>> relative paths aren't used by the agent.
>
> This is still relevant and applicable.

Id leave as it is if that is not causing any bugs, we do intend to
move away from glib at some point.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] obex: Use GLib helper function to manipulate paths
  2017-11-24 15:12   ` Luiz Augusto von Dentz
@ 2017-11-24 15:18     ` Bastien Nocera
  0 siblings, 0 replies; 4+ messages in thread
From: Bastien Nocera @ 2017-11-24 15:18 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

On Fri, 2017-11-24 at 17:12 +0200, Luiz Augusto von Dentz wrote:
> Hi Bastien,
> 
> On Fri, Nov 24, 2017 at 4:12 PM, Bastien Nocera <hadess@hadess.net>
> wrote:
> > On Sat, 2013-11-09 at 18:18 +0100, Bastien Nocera wrote:
> > > Instead of trying to do it by hand. This also makes sure that
> > > relative paths aren't used by the agent.
> > 
> > This is still relevant and applicable.
> 
> Id leave as it is if that is not causing any bugs, we do intend to
> move away from glib at some point.

I'm pretty sure that the existing code isn't secure and passing a
relative path as the name will make it break out of the expected
destination folder.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-24 15:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-09 17:18 [PATCH] obex: Use GLib helper function to manipulate paths Bastien Nocera
2017-11-24 14:12 ` Bastien Nocera
2017-11-24 15:12   ` Luiz Augusto von Dentz
2017-11-24 15:18     ` Bastien Nocera

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.