Ensure returned path is not a dangerous one
Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
This commit is contained in:
parent
776da644eb
commit
45064b6b7b
1 changed files with 12 additions and 8 deletions
20
src/util.cpp
20
src/util.cpp
|
@ -704,12 +704,14 @@ const fs::path &GetBlocksDir(bool fNetSpecific)
|
||||||
if (gArgs.IsArgSet("-blocksdir")) {
|
if (gArgs.IsArgSet("-blocksdir")) {
|
||||||
path = fs::system_complete(gArgs.GetArg("-blocksdir", ""));
|
path = fs::system_complete(gArgs.GetArg("-blocksdir", ""));
|
||||||
if (!fs::is_directory(path)) {
|
if (!fs::is_directory(path)) {
|
||||||
path = "";
|
LogPrintf("%s: %s is not a directory, fallback to GetDataDir\n", __func__, path);
|
||||||
return path;
|
path.clear();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
path = GetDataDir(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (path.empty())
|
||||||
|
path = GetDataDir(false);
|
||||||
|
|
||||||
if (fNetSpecific)
|
if (fNetSpecific)
|
||||||
path /= BaseParams().DataDir();
|
path /= BaseParams().DataDir();
|
||||||
|
|
||||||
|
@ -733,12 +735,14 @@ const fs::path &GetDataDir(bool fNetSpecific)
|
||||||
if (gArgs.IsArgSet("-datadir")) {
|
if (gArgs.IsArgSet("-datadir")) {
|
||||||
path = fs::system_complete(gArgs.GetArg("-datadir", ""));
|
path = fs::system_complete(gArgs.GetArg("-datadir", ""));
|
||||||
if (!fs::is_directory(path)) {
|
if (!fs::is_directory(path)) {
|
||||||
path = "";
|
LogPrintf("%s: %s is not a directory, fallback to GetDefaultDataDir\n", __func__, path);
|
||||||
return path;
|
path.clear();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
path = GetDefaultDataDir();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (path.empty())
|
||||||
|
path = GetDefaultDataDir();
|
||||||
|
|
||||||
if (fNetSpecific)
|
if (fNetSpecific)
|
||||||
path /= BaseParams().DataDir();
|
path /= BaseParams().DataDir();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue