[PATCH] D17104: [VFS] Drop path traversal assertion

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 10 15:04:57 PST 2016


bruno added a comment.

In http://reviews.llvm.org/D17104#349141, @benlangmuir wrote:

> Please clarify what you mean here:
>
> > The rationale is that if source and destination paths in the YAML file contain ".." this is enough
>
> >  for the file manager to retrieve the right file, meaning that it doesn't matter how we write it
>
> >  since the FileManager is capable of transforming it in real/feasible paths.
>
>
> The VFS layer does not have access to the FileManager.  I agree that ".." in a destination path should be fine.  But ".." in a source path will only work if we have code in the redirecting file system to handle ".." explicitly, which AFAICT we don't:
>
>   RedirectingFileSystem::lookupPath(sys::path::const_iterator Start,
>                                     sys::path::const_iterator End, Entry *From) {
>     if (Start->equals("."))
>       ++Start;
>  
>     // FIXME: handle ..
>


What I mean here is that if you ask the FileManager for "/llvm-install/bin/../lib/clang/3.8.0/include/__stddef_max_align_t.h", it will successfully invoke VFS code and find "<whatever_path_to_cache>/vfs/llvm-install/bin/../lib/clang/3.8.0/include/__stddef_max_align_t.h". Since ".." is split into its own path component, it will compare ".." in Start and From, succeed and the search will continue. Probably this traversal code was not initially meant to work this way, but the actual fact is that it does.

The test in the patch tests exactly that.


http://reviews.llvm.org/D17104





More information about the cfe-commits mailing list