]> granicus.if.org Git - clang/commit
Reapply: [VFS] Add support for handling path traversals
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Wed, 16 Mar 2016 04:39:38 +0000 (04:39 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Wed, 16 Mar 2016 04:39:38 +0000 (04:39 +0000)
commitf4dd47a7648ef444ad2d4a179d77d7bc1a065c38
tree94cfe3ab51d9f646ba9b7cfb4359be75e8d1b0a2
parent65556141a6f06dba23767c73025123e74427048a
Reapply: [VFS] Add support for handling path traversals

This is originally r261551, reverted because of windows bots failing on
unittests. Change the current behavior to do not handle path traversals
on windows.

Handle ".", ".." and "./" with trailing slashes while collecting files
to be dumped into the vfs overlay directory.

Include the support for symlinks into components. Given the path:

/install-dir/bin/../lib/clang/3.8.0/include/altivec.h, if "bin"
component is a symlink, it's not safe to use `path::remove_dots` here,
and `realpath` is used to get the right answer. Since `realpath`
is expensive, we only do it at collecting time (which only happens
during the crash reproducer) and cache the base directory for fast lookups.

Overall, this makes the input to the VFS YAML file to be canonicalized
to never contain traversal components.

Differential Revision: http://reviews.llvm.org/D17104

rdar://problem/24499339

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263617 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Basic/VirtualFileSystem.cpp
lib/Frontend/ModuleDependencyCollector.cpp
test/Modules/crash-vfs-path-symlink-component.m [new file with mode: 0644]
test/Modules/crash-vfs-path-traversal.m [new file with mode: 0644]