From 954d7433bd8c10bce917326f70070077f0cfc165 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Thu, 9 Aug 2018 20:37:49 +0200 Subject: Disallow remappings with empty prefix. --- solc/CommandLineInterface.cpp | 15 +++++++++++++-- solc/CommandLineInterface.h | 2 ++ 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'solc') diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index 429bd637..f7d1c748 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -392,7 +392,18 @@ bool CommandLineInterface::readInputFilesAndConfigureRemappings() { auto eq = find(path.begin(), path.end(), '='); if (eq != path.end()) - path = string(eq + 1, path.end()); + { + if (auto r = CompilerStack::parseRemapping(path)) + { + m_remappings.emplace_back(std::move(*r)); + path = string(eq + 1, path.end()); + } + else + { + cerr << "Invalid remapping: \"" << path << "\"." << endl; + return false; + } + } else if (path == "-") addStdin = true; else @@ -808,7 +819,7 @@ bool CommandLineInterface::processInput() if (m_args.count(g_argMetadataLiteral) > 0) m_compiler->useMetadataLiteralSources(true); if (m_args.count(g_argInputFile)) - m_compiler->setRemappings(m_args[g_argInputFile].as>()); + m_compiler->setRemappings(m_remappings); for (auto const& sourceCode: m_sourceCodes) m_compiler->addSource(sourceCode.first, sourceCode.second); if (m_args.count(g_argLibraries)) diff --git a/solc/CommandLineInterface.h b/solc/CommandLineInterface.h index 45ec1eb5..010dce34 100644 --- a/solc/CommandLineInterface.h +++ b/solc/CommandLineInterface.h @@ -97,6 +97,8 @@ private: boost::program_options::variables_map m_args; /// map of input files to source code strings std::map m_sourceCodes; + /// list of remappings + std::vector m_remappings; /// list of allowed directories to read files from std::vector m_allowedDirectories; /// map of library names to addresses -- cgit