Whitelist base path

This commit is contained in:
Kamil Śliwak
2021-09-27 13:14:10 +02:00
parent 52dd39212d
commit 3ac3612767
7 changed files with 28 additions and 48 deletions
+2 -1
View File
@@ -70,9 +70,10 @@ ReadCallback::Result FileReader::readFile(string const& _kind, string const& _so
strippedSourceUnitName.erase(0, 7);
auto canonicalPath = normalizeCLIPathForVFS(m_basePath / strippedSourceUnitName, SymlinkResolution::Enabled);
FileSystemPathSet extraAllowedPaths = {m_basePath.empty() ? "." : m_basePath};
bool isAllowed = false;
for (boost::filesystem::path const& allowedDir: m_allowedDirectories)
for (boost::filesystem::path const& allowedDir: m_allowedDirectories + extraAllowedPaths)
if (isPathPrefix(normalizeCLIPathForVFS(allowedDir, SymlinkResolution::Enabled), canonicalPath))
{
isAllowed = true;