mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Store non-canonical version.
This commit is contained in:
parent
efad1e05ac
commit
e90ebcd63b
@ -531,17 +531,17 @@ bool CommandLineInterface::processInput()
|
|||||||
|
|
||||||
CompilerStack::ReadFileCallback fileReader = [this](string const& _path)
|
CompilerStack::ReadFileCallback fileReader = [this](string const& _path)
|
||||||
{
|
{
|
||||||
auto boostPath = boost::filesystem::path(_path);
|
auto path = boost::filesystem::path(_path);
|
||||||
if (!boost::filesystem::exists(boostPath))
|
if (!boost::filesystem::exists(path))
|
||||||
return CompilerStack::ReadFileResult{false, "File not found."};
|
return CompilerStack::ReadFileResult{false, "File not found."};
|
||||||
boostPath = boost::filesystem::canonical(boostPath);
|
auto canonicalPath = boost::filesystem::canonical(path);
|
||||||
bool isAllowed = false;
|
bool isAllowed = false;
|
||||||
for (auto const& allowedDir: m_allowedDirectories)
|
for (auto const& allowedDir: m_allowedDirectories)
|
||||||
{
|
{
|
||||||
// If dir is a prefix of boostPath, we are fine.
|
// If dir is a prefix of boostPath, we are fine.
|
||||||
if (
|
if (
|
||||||
std::distance(allowedDir.begin(), allowedDir.end()) <= std::distance(boostPath.begin(), boostPath.end()) &&
|
std::distance(allowedDir.begin(), allowedDir.end()) <= std::distance(canonicalPath.begin(), canonicalPath.end()) &&
|
||||||
std::equal(allowedDir.begin(), allowedDir.end(), boostPath.begin())
|
std::equal(allowedDir.begin(), allowedDir.end(), canonicalPath.begin())
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
isAllowed = true;
|
isAllowed = true;
|
||||||
@ -550,12 +550,12 @@ bool CommandLineInterface::processInput()
|
|||||||
}
|
}
|
||||||
if (!isAllowed)
|
if (!isAllowed)
|
||||||
return CompilerStack::ReadFileResult{false, "File outside of allowed directories."};
|
return CompilerStack::ReadFileResult{false, "File outside of allowed directories."};
|
||||||
else if (!boost::filesystem::is_regular_file(boostPath))
|
else if (!boost::filesystem::is_regular_file(canonicalPath))
|
||||||
return CompilerStack::ReadFileResult{false, "Not a valid file."};
|
return CompilerStack::ReadFileResult{false, "Not a valid file."};
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto contents = dev::contentsString(boostPath.string());
|
auto contents = dev::contentsString(canonicalPath.string());
|
||||||
m_sourceCodes[boostPath.string()] = contents;
|
m_sourceCodes[path.string()] = contents;
|
||||||
return CompilerStack::ReadFileResult{true, contents};
|
return CompilerStack::ReadFileResult{true, contents};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user