From 7c270e68830562982045239a2b006a0503647a8a Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Tue, 6 Aug 2024 17:40:25 +0000 Subject: [PATCH] merge bitcoin#24026: Block unsafe std::string fs::path conversion copy_file calls --- src/fs.h | 7 +++++++ src/interfaces/wallet.h | 4 ++-- src/wallet/interfaces.cpp | 2 +- src/wallet/rpcwallet.cpp | 2 +- src/wallet/wallet.cpp | 6 +++--- src/wallet/wallet.h | 3 ++- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/fs.h b/src/fs.h index 3cf4371fb4..80dd2c03d3 100644 --- a/src/fs.h +++ b/src/fs.h @@ -92,6 +92,13 @@ static inline path operator+(path p1, path p2) return p1; } +// Disallow implicit std::string conversion for copy_file +// to avoid locale-dependent encoding on Windows. +static inline void copy_file(const path& from, const path& to, copy_option options) +{ + boost::filesystem::copy_file(from, to, options); +} + /** * Convert path object to byte string. On POSIX, paths natively are byte * strings, so this is trivial. On Windows, paths natively are Unicode, so an diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index 32fb6b28e8..3bae75ed6f 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -6,7 +6,7 @@ #define BITCOIN_INTERFACES_WALLET_H #include // For CAmount -#include // For fs::path +#include #include // For ChainClient #include // For CKeyID and CScriptID (definitions needed in CTxDestination instantiation) #include