diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-09-21 22:48:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-21 22:48:05 +0800 |
commit | 5dd3ee2d9657f18b9b2797755e1216b93b67316c (patch) | |
tree | 35061bccccac5d6ebd2e7dce945255fabaf66c9a /libsolidity | |
parent | 8f96fe698df64b5f35b7177621d4861b85167957 (diff) | |
parent | a51517390078df02be6cc57586f4f1c142440144 (diff) | |
download | dexon-solidity-5dd3ee2d9657f18b9b2797755e1216b93b67316c.tar.gz dexon-solidity-5dd3ee2d9657f18b9b2797755e1216b93b67316c.tar.zst dexon-solidity-5dd3ee2d9657f18b9b2797755e1216b93b67316c.zip |
Merge pull request #5050 from ethereum/standard-json-crashes
Add proper error reporting when invalid settings are provided in StandardJSON
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/interface/StandardCompiler.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index c1996777..b53c5a5e 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -280,6 +280,8 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input) for (auto const& url: sources[sourceName]["urls"]) { + if (!url.isString()) + return formatFatalError("JSONError", "URL must be a string."); ReadCallback::Result result = m_readFile(url.asString()); if (result.success) { @@ -320,7 +322,9 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input) if (settings.isMember("evmVersion")) { - boost::optional<EVMVersion> version = EVMVersion::fromString(settings.get("evmVersion", {}).asString()); + if (!settings["evmVersion"].isString()) + return formatFatalError("JSONError", "evmVersion must be a string."); + boost::optional<EVMVersion> version = EVMVersion::fromString(settings["evmVersion"].asString()); if (!version) return formatFatalError("JSONError", "Invalid EVM version requested."); m_compilerStack.setEVMVersion(*version); @@ -329,6 +333,8 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input) vector<CompilerStack::Remapping> remappings; for (auto const& remapping: settings.get("remappings", Json::Value())) { + if (!remapping.isString()) + return formatFatalError("JSONError", "Remapping entry must be a string."); if (auto r = CompilerStack::parseRemapping(remapping.asString())) remappings.emplace_back(std::move(*r)); else @@ -349,9 +355,11 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input) { auto const& jsonSourceName = jsonLibraries[sourceName]; if (!jsonSourceName.isObject()) - return formatFatalError("JSONError", "library entry is not a JSON object."); + return formatFatalError("JSONError", "Library entry is not a JSON object."); for (auto const& library: jsonSourceName.getMemberNames()) { + if (!jsonSourceName[library].isString()) + return formatFatalError("JSONError", "Library address must be a string."); string address = jsonSourceName[library].asString(); if (!boost::starts_with(address, "0x")) |