aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/interface
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-03-01 19:37:14 +0800
committerGitHub <noreply@github.com>2018-03-01 19:37:14 +0800
commit2c82f748bb91a7c44ae112f5f4fc22bb63d7f861 (patch)
treeedb6821c94c1a76b50e3dfb5d990ee95ea176ad3 /libsolidity/interface
parentc123fa26f3a90090aa6d8f8ec028e362bfdb73a0 (diff)
parentb6dfd9ef5422d80177b622fc2c486de00fcc0f73 (diff)
downloaddexon-solidity-2c82f748bb91a7c44ae112f5f4fc22bb63d7f861.tar
dexon-solidity-2c82f748bb91a7c44ae112f5f4fc22bb63d7f861.tar.gz
dexon-solidity-2c82f748bb91a7c44ae112f5f4fc22bb63d7f861.tar.bz2
dexon-solidity-2c82f748bb91a7c44ae112f5f4fc22bb63d7f861.tar.lz
dexon-solidity-2c82f748bb91a7c44ae112f5f4fc22bb63d7f861.tar.xz
dexon-solidity-2c82f748bb91a7c44ae112f5f4fc22bb63d7f861.tar.zst
dexon-solidity-2c82f748bb91a7c44ae112f5f4fc22bb63d7f861.zip
Merge pull request #3624 from ethereum/jsonio-libraries-hex
Ensure that library addresses supplied are of correct length and hex prefixed
Diffstat (limited to 'libsolidity/interface')
-rw-r--r--libsolidity/interface/StandardCompiler.cpp20
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."
);
}
}