mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-06 13:47:56 +02:00
refactor: Block unsafe fs::path std::string conversion calls
There is no change in behavior. This just helps prepare for the transition from boost::filesystem to std::filesystem by avoiding calls to methods which will be unsafe after the transaction to std::filesystem to due lack of a boost::filesystem::path::imbue equivalent and inability to set a predictable locale. Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Co-authored-by: Kiminuo <kiminuo@protonmail.com> Co-authored-by: MarcoFalke <falke.marco@gmail.com>
This commit is contained in:
@@ -70,7 +70,7 @@ static fs::path GetAuthCookieFile(bool temp=false)
|
||||
if (temp) {
|
||||
arg += ".tmp";
|
||||
}
|
||||
return AbsPathForConfigVal(fs::path(arg));
|
||||
return AbsPathForConfigVal(fs::PathFromString(arg));
|
||||
}
|
||||
|
||||
bool GenerateAuthCookie(std::string *cookie_out)
|
||||
@@ -87,7 +87,7 @@ bool GenerateAuthCookie(std::string *cookie_out)
|
||||
fs::path filepath_tmp = GetAuthCookieFile(true);
|
||||
file.open(filepath_tmp);
|
||||
if (!file.is_open()) {
|
||||
LogPrintf("Unable to open cookie authentication file %s for writing\n", filepath_tmp.string());
|
||||
LogPrintf("Unable to open cookie authentication file %s for writing\n", fs::PathToString(filepath_tmp));
|
||||
return false;
|
||||
}
|
||||
file << cookie;
|
||||
@@ -95,10 +95,10 @@ bool GenerateAuthCookie(std::string *cookie_out)
|
||||
|
||||
fs::path filepath = GetAuthCookieFile(false);
|
||||
if (!RenameOver(filepath_tmp, filepath)) {
|
||||
LogPrintf("Unable to rename cookie authentication file %s to %s\n", filepath_tmp.string(), filepath.string());
|
||||
LogPrintf("Unable to rename cookie authentication file %s to %s\n", fs::PathToString(filepath_tmp), fs::PathToString(filepath));
|
||||
return false;
|
||||
}
|
||||
LogPrintf("Generated RPC authentication cookie %s\n", filepath.string());
|
||||
LogPrintf("Generated RPC authentication cookie %s\n", fs::PathToString(filepath));
|
||||
|
||||
if (cookie_out)
|
||||
*cookie_out = cookie;
|
||||
|
||||
Reference in New Issue
Block a user