diff options
author | Ross Lagerwall <rosslagerwall@gmail.com> | 2015-09-20 15:15:51 +0100 |
---|---|---|
committer | Ross Lagerwall <rosslagerwall@gmail.com> | 2015-09-27 22:30:22 +0100 |
commit | eefdc161bc016d9f5f8a5122e7c9eb75769078ed (patch) | |
tree | 2cf96671e3fd4fd425cce29faa3073418e9d8659 /daemon | |
parent | d1a53acf98d152f7e22fcf05ed9e2661b81334aa (diff) | |
download | gvfs-eefdc161bc016d9f5f8a5122e7c9eb75769078ed.tar.gz |
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
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/gvfsftpdircache.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/daemon/gvfsftpdircache.c b/daemon/gvfsftpdircache.c index b123e4e8..0412ed42 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) |