diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2018-02-28 23:57:35 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-03-01 19:03:56 +0800 |
commit | b6dfd9ef5422d80177b622fc2c486de00fcc0f73 (patch) | |
tree | a1b20ed0c80eae0bf01597070fb62a22cf17ba33 /libsolidity/interface/StandardCompiler.cpp | |
parent | 9e3da89a7a0753e869b4668f9587385c9b37ba8d (diff) | |
download | dexon-solidity-b6dfd9ef5422d80177b622fc2c486de00fcc0f73.tar dexon-solidity-b6dfd9ef5422d80177b622fc2c486de00fcc0f73.tar.gz dexon-solidity-b6dfd9ef5422d80177b622fc2c486de00fcc0f73.tar.bz2 dexon-solidity-b6dfd9ef5422d80177b622fc2c486de00fcc0f73.tar.lz dexon-solidity-b6dfd9ef5422d80177b622fc2c486de00fcc0f73.tar.xz dexon-solidity-b6dfd9ef5422d80177b622fc2c486de00fcc0f73.tar.zst dexon-solidity-b6dfd9ef5422d80177b622fc2c486de00fcc0f73.zip |
Ensure that library addresses supplied are of correct length and hex prefixed in JSONIO
Diffstat (limited to 'libsolidity/interface/StandardCompiler.cpp')
-rw-r--r-- | libsolidity/interface/StandardCompiler.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 8c64c164..91fe72ae 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -27,6 +27,8 @@ #include <libdevcore/JSON.h> #include <libdevcore/SHA3.h> +#include <boost/algorithm/string.hpp> + using namespace std; using namespace dev; using namespace dev::solidity; @@ -337,16 +339,30 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input) return formatFatalError("JSONError", "library entry is not a JSON object."); for (auto const& library: jsonSourceName.getMemberNames()) { + string address = jsonSourceName[library].asString(); + + if (!boost::starts_with(address, "0x")) + return formatFatalError( + "JSONError", + "Library address is not prefixed with \"0x\"." + ); + + if (address.length() != 42) + return formatFatalError( + "JSONError", + "Library address is of invalid length." + ); + try { // @TODO use libraries only for the given source - libraries[library] = h160(jsonSourceName[library].asString()); + libraries[library] = h160(address); } catch (dev::BadHexCharacter) { return formatFatalError( "JSONError", - "Invalid library address (\"" + jsonSourceName[library].asString() + "\") supplied." + "Invalid library address (\"" + address + "\") supplied." ); } } |