From 6bb54708e6457f21596793a7149dc6dfea1dc871 Mon Sep 17 00:00:00 2001 From: nthumann Date: Wed, 4 Aug 2021 12:07:31 +0200 Subject: util: Check if specified config file cannot be opened --- src/util/system.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/util/system.cpp b/src/util/system.cpp index 258ba2f235..85a23731a2 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -904,6 +904,11 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys) const std::string confPath = GetArg("-conf", BITCOIN_CONF_FILENAME); fsbridge::ifstream stream(GetConfigFile(confPath)); + // not ok to have a config file specified that cannot be opened + if (IsArgSet("-conf") && !stream.good()) { + error = strprintf("specified config file \"%s\" could not be opened.", confPath); + return false; + } // ok to not have a config file if (stream.good()) { if (!ReadConfigStream(stream, confPath, error, ignore_invalid_keys)) { -- cgit v1.2.3