mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
Merge ElementsProject/elements#1012: fuzz: backport fixes to fuzzer errors
0896d0a278util: Properly handle -noincludeconf on command line (MarcoFalke)5f18d337d4Cleanup -includeconf error message (MarcoFalke)99b86594dfFix crash when parsing command line with -noincludeconf=0 (MarcoFalke)c98902bd1bfuzz: add missing ECCVerifyHandle to base_encode_decode (Andrew Poelstra) Pull request description: Backport of https://github.com/bitcoin/bitcoin/pull/22279 and https://github.com/bitcoin/bitcoin/pull/22002 and https://github.com/bitcoin/bitcoin/pull/22137 ACKs for top commit: jonasnick: utACK0896d0a278Tree-SHA512: 7a9c4a20fc51ac3e66fd0b8d6f28200b9342774fcb003c561e277fab4a68c3ebd2cab4c3081170199a51aabf3956e0f7248fa6c853c8aa971645fb9039adc688
This commit is contained in:
commit
bd2e2d5c64
4 changed files with 39 additions and 7 deletions
|
|
@ -14,6 +14,11 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
void initialize()
|
||||
{
|
||||
static const ECCVerifyHandle verify_handle;
|
||||
}
|
||||
|
||||
void test_one_input(const std::vector<uint8_t>& buffer)
|
||||
{
|
||||
const std::string random_encoded_string(buffer.begin(), buffer.end());
|
||||
|
|
|
|||
|
|
@ -318,6 +318,25 @@ BOOST_FIXTURE_TEST_CASE(util_CheckValue, CheckValueTest)
|
|||
CheckValue(M::ALLOW_ANY, "-value=abc", Expect{"abc"}.String("abc").Int(0).Bool(false).List({"abc"}));
|
||||
}
|
||||
|
||||
struct NoIncludeConfTest {
|
||||
std::string Parse(const char* arg)
|
||||
{
|
||||
TestArgsManager test;
|
||||
test.SetupArgs({{"-includeconf", ArgsManager::ALLOW_ANY}});
|
||||
std::array<const char*, 2> argv{"ignored", arg};
|
||||
std::string error;
|
||||
(void)test.ParseParameters(argv.size(), argv.data(), error);
|
||||
return error;
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(util_NoIncludeConf, NoIncludeConfTest)
|
||||
{
|
||||
BOOST_CHECK_EQUAL(Parse("-noincludeconf"), "");
|
||||
BOOST_CHECK_EQUAL(Parse("-includeconf"), "-includeconf cannot be used from commandline; -includeconf=\"\"");
|
||||
BOOST_CHECK_EQUAL(Parse("-includeconf=file"), "-includeconf cannot be used from commandline; -includeconf=\"file\"");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(util_ParseParameters)
|
||||
{
|
||||
TestArgsManager testArgs;
|
||||
|
|
|
|||
|
|
@ -324,15 +324,16 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
|
|||
m_settings.command_line_options[key].push_back(value);
|
||||
}
|
||||
|
||||
// we do not allow -includeconf from command line
|
||||
bool success = true;
|
||||
// we do not allow -includeconf from command line, only -noincludeconf
|
||||
if (auto* includes = util::FindKey(m_settings.command_line_options, "includeconf")) {
|
||||
for (const auto& include : util::SettingsSpan(*includes)) {
|
||||
error += "-includeconf cannot be used from commandline; -includeconf=" + include.get_str() + "\n";
|
||||
success = false;
|
||||
const util::SettingsSpan values{*includes};
|
||||
// Range may be empty if -noincludeconf was passed
|
||||
if (!values.empty()) {
|
||||
error = "-includeconf cannot be used from commandline; -includeconf=" + values.begin()->write();
|
||||
return false; // pick first value as example
|
||||
}
|
||||
}
|
||||
return success;
|
||||
return true;
|
||||
}
|
||||
|
||||
Optional<unsigned int> ArgsManager::GetArgFlags(const std::string& name) const
|
||||
|
|
|
|||
|
|
@ -43,7 +43,14 @@ class IncludeConfTest(BitcoinTestFramework):
|
|||
|
||||
self.log.info("-includeconf cannot be used as command-line arg")
|
||||
self.stop_node(0)
|
||||
self.nodes[0].assert_start_raises_init_error(extra_args=["-includeconf=relative2.conf"], expected_msg="Error: Error parsing command line arguments: -includeconf cannot be used from commandline; -includeconf=relative2.conf")
|
||||
self.nodes[0].assert_start_raises_init_error(
|
||||
extra_args=['-noincludeconf=0'],
|
||||
expected_msg='Error: Error parsing command line arguments: -includeconf cannot be used from commandline; -includeconf=true',
|
||||
)
|
||||
self.nodes[0].assert_start_raises_init_error(
|
||||
extra_args=['-includeconf=relative2.conf', '-includeconf=no_warn.conf'],
|
||||
expected_msg='Error: Error parsing command line arguments: -includeconf cannot be used from commandline; -includeconf="relative2.conf"',
|
||||
)
|
||||
|
||||
self.log.info("-includeconf cannot be used recursively. subversion should end with 'main; relative)/'")
|
||||
with open(os.path.join(self.options.tmpdir, "node0", "relative.conf"), "a", encoding="utf8") as f:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue