aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-04-21 03:31:27 +0800
committerGitHub <noreply@github.com>2017-04-21 03:31:27 +0800
commited64c849f57b9aeed1eda4563f0d4340013420ef (patch)
tree731821dd8110a975096bbbb4d318fbb4d9bb0dcd
parent2ccbc088f24a8a215072cbf919d80cb503aac89f (diff)
parentb30fad4a49b911577c0c04ef9dadaf7ea0617b28 (diff)
downloaddexon-solidity-ed64c849f57b9aeed1eda4563f0d4340013420ef.tar.gz
dexon-solidity-ed64c849f57b9aeed1eda4563f0d4340013420ef.tar.zst
dexon-solidity-ed64c849f57b9aeed1eda4563f0d4340013420ef.zip
Merge pull request #2145 from ethereum/cli-readfile-permissions
Check for path permissions before opening file in the CLI file reader
-rw-r--r--solc/CommandLineInterface.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp
index a622fcfe..49dfd0b5 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -660,8 +660,6 @@ bool CommandLineInterface::processInput()
ReadFile::Callback fileReader = [this](string const& _path)
{
auto path = boost::filesystem::path(_path);
- if (!boost::filesystem::exists(path))
- return ReadFile::Result{false, "File not found."};
auto canonicalPath = boost::filesystem::canonical(path);
bool isAllowed = false;
for (auto const& allowedDir: m_allowedDirectories)
@@ -678,6 +676,8 @@ bool CommandLineInterface::processInput()
}
if (!isAllowed)
return ReadFile::Result{false, "File outside of allowed directories."};
+ else if (!boost::filesystem::exists(path))
+ return ReadFile::Result{false, "File not found."};
else if (!boost::filesystem::is_regular_file(canonicalPath))
return ReadFile::Result{false, "Not a valid file."};
else