aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-04-21 03:01:17 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-04-21 03:01:17 +0800
commitb30fad4a49b911577c0c04ef9dadaf7ea0617b28 (patch)
treef6688ef11001015f475db7efa9e9871cf367cc89
parent965de29772963b640b00579fa8225bb662599ecd (diff)
downloaddexon-solidity-b30fad4a49b911577c0c04ef9dadaf7ea0617b28.tar.gz
dexon-solidity-b30fad4a49b911577c0c04ef9dadaf7ea0617b28.tar.zst
dexon-solidity-b30fad4a49b911577c0c04ef9dadaf7ea0617b28.zip
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 76102b53..d115d5ab 100644
--- a/solc/CommandLineInterface.cpp
+++ b/solc/CommandLineInterface.cpp
@@ -638,8 +638,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)
@@ -656,6 +654,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