[gvfs] ftp: Sanitize absolute symlink paths when resolving
- From: Ross Lagerwall <rossl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] ftp: Sanitize absolute symlink paths when resolving
- Date: Sun, 27 Sep 2015 21:30:48 +0000 (UTC)
commit eefdc161bc016d9f5f8a5122e7c9eb75769078ed
Author: Ross Lagerwall <rosslagerwall gmail com>
Date: Sun Sep 20 15:15:51 2015 +0100
ftp: Sanitize absolute symlink paths when resolving
The existing code sanitizes relative symlinks but not absolute symlinks
when resolving them. But this can cause issues when looking up the
resolved path (e.g. if it has a trailing slash, the correct information
will not be returned because it will not get the parent directory
correctly).
To fix this, sanitize both absolute and relative paths.
https://bugzilla.gnome.org/show_bug.cgi?id=755303
daemon/gvfsftpdircache.c | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/daemon/gvfsftpdircache.c b/daemon/gvfsftpdircache.c
index b123e4e..0412ed4 100644
--- a/daemon/gvfsftpdircache.c
+++ b/daemon/gvfsftpdircache.c
@@ -750,13 +750,18 @@ g_vfs_ftp_dir_cache_funcs_resolve_default (GVfsFtpTask * task,
g_return_val_if_fail (target != NULL, NULL);
if (target[0] == '/')
- return g_vfs_ftp_file_new_from_ftp (task->backend, target);
+ {
+ new_path = g_string_new (target);
+ }
+ else
+ {
+ new_path = g_string_new (g_vfs_ftp_file_get_ftp_path (file));
+ /* only take directory */
+ match = strrchr (new_path->str, '/');
+ g_string_truncate (new_path, match - new_path->str + 1);
+ g_string_append (new_path, target);
+ }
- new_path = g_string_new (g_vfs_ftp_file_get_ftp_path (file));
- /* only take directory */
- match = strrchr (new_path->str, '/');
- g_string_truncate (new_path, match - new_path->str + 1);
- g_string_append (new_path, target);
g_string_append_c (new_path, '/'); /* slash at end makes code easier */
/* cleanup: remove all double slashes */
while ((match = strstr (new_path->str, "//")) != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]