aboutsummaryrefslogtreecommitdiff
path: root/src/util/system.cpp
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2021-06-07 13:20:11 +0800
committerfanquake <fanquake@gmail.com>2021-06-07 13:20:57 +0800
commit791f985a60726febca3053453c2710407529fd0a (patch)
tree4cf1aa3e8e53f239e96abd857a78917357fb8e95 /src/util/system.cpp
parent260b1d74fee17b64f7a69eca30e4811b961325b5 (diff)
parentfa910b47656d0e69cccb1f31804f2b11aa45d053 (diff)
Merge bitcoin/bitcoin#22137: util: Properly handle -noincludeconf on command line (take 2)
fa910b47656d0e69cccb1f31804f2b11aa45d053 util: Properly handle -noincludeconf on command line (MarcoFalke) Pull request description: Before: ``` $ ./src/qt/bitcoin-qt -noincludeconf (memory violation, can be observed with valgrind or similar) ``` After: ``` $ ./src/qt/bitcoin-qt -noincludeconf (passes startup) ``` Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34884 ACKs for top commit: practicalswift: cr ACK fa910b47656d0e69cccb1f31804f2b11aa45d053: patch looks correct ryanofsky: Code review ACK fa910b47656d0e69cccb1f31804f2b11aa45d053. Nice cleanups! Tree-SHA512: 5dfad82a78bca7a9a6bcc6aead2d7fbde166a09a5300a82f80dd1aee1de00e070bcb30b7472741a5396073b370898696e78c33038f94849219281d99358248ed
Diffstat (limited to 'src/util/system.cpp')
-rw-r--r--src/util/system.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp
index 5b87806a45..13ccf7463e 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -365,11 +365,14 @@ 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
+ // we do not allow -includeconf from command line, only -noincludeconf
if (auto* includes = util::FindKey(m_settings.command_line_options, "includeconf")) {
- const auto& include{*util::SettingsSpan(*includes).begin()}; // pick first value as example
- error = "-includeconf cannot be used from commandline; -includeconf=" + include.write();
- return 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 true;
}