0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-04 10:07:27 -05:00
bitcoin-bitcoin-core/src/util
W. J. van der Laan 1884ce2f4c
Merge bitcoin/bitcoin#22937: refactor: Forbid calling unsafe fs::path(std::string) constructor and fs::path::string() method
6544ea5035 refactor: Block unsafe fs::path std::string conversion calls (Russell Yanofsky)
b39a477ec6 refactor: Add fs::PathToString, fs::PathFromString, u8string, u8path functions (Russell Yanofsky)

Pull request description:

  The `fs::path` class has a `std::string` constructor which will implicitly convert from strings. Implicit conversions like this are not great in general because they can hide complexity and inefficiencies in the code, but this case is especially bad, because after the transition from `boost::filesystem` to `std::filesystem` in #20744 the behavior of this constructor on windows will be more complicated and can mangle path strings. The `fs::path` class also has a `.string()` method which is inverse of the constructor and has the same problems.

  Fix this by replacing the unsafe method calls with `PathToString` and `PathFromString` function calls, and by forbidding unsafe method calls in the future.

ACKs for top commit:
  kiminuo:
    ACK 6544ea5035
  laanwj:
    Code review ACK 6544ea5035
  hebasto:
    re-ACK 6544ea5035, only added `fsbridge_stem` test case, updated comment, and rebased since my [previous](https://github.com/bitcoin/bitcoin/pull/22937#pullrequestreview-765503126) review. Verified with the following command:

Tree-SHA512: c36324740eb4ee55151146626166c00d5ccc4b6f3df777e75c112bcb4d1db436c1d9cc8c29a1e7fb96051457d317961ab42e6c380c3be2771d135771b2b49fa0
2021-10-15 10:01:56 +02:00
..
asmap.cpp refactor: Block unsafe fs::path std::string conversion calls 2021-10-05 11:10:47 -04:00
asmap.h [asmap] Make DecodeAsmap() a utility function 2021-09-07 15:24:00 +01:00
bip32.cpp scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
bip32.h scripted-diff: Use [[nodiscard]] (C++17) instead of NODISCARD 2020-11-26 09:05:59 +00:00
bytevectorhash.cpp
bytevectorhash.h
check.h util: Make Assume() usable as unary expression 2021-03-04 12:03:50 +01:00
epochguard.h mempool: apply rule of 5 to epochguard.h, fix compiler warnings 2021-07-20 13:58:14 +02:00
error.cpp rpc: send: support external signer 2021-02-23 14:34:32 +01:00
error.h rpc: send: support external signer 2021-02-23 14:34:32 +01:00
fees.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
fees.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
getuniquepath.cpp doc: add missing copyright header to getuniquepath.cpp 2021-09-08 16:28:21 +08:00
getuniquepath.h Introduce GetUniquePath(base) helper method to replace boost::filesystem::unique_path() which is not available in std::filesystem. 2021-02-04 11:38:09 +01:00
golombrice.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
hash_type.h move-only: Add util/hash_type 2021-05-11 10:38:18 +02:00
hasher.cpp Add generic SaltedSipHasher 2020-11-10 14:33:37 -05:00
hasher.h doc: remove outdated comment 2021-08-22 17:32:43 +02:00
macros.h refactor: Move STRINGIZE macro to macros.h 2021-02-01 22:30:05 +02:00
message.cpp Replace boost::variant with std::variant 2021-01-05 10:10:50 +01:00
message.h Move direct calls to MessageSign into new SignMessage functions in CWallet and ScriptPubKeyMan 2020-03-09 11:16:20 -04:00
moneystr.cpp Merge bitcoin/bitcoin#22951: consensus: move amount.h into consensus 2021-10-05 09:43:23 +02:00
moneystr.h [MOVEONLY] consensus: move amount.h into consensus 2021-09-30 07:41:57 +08:00
rbf.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
rbf.h make MAX_BIP125_RBF_SEQUENCE constexpr 2021-09-20 13:32:28 +01:00
readwritefile.cpp util: fix WriteBinaryFile() claiming success even if error occurred 2021-03-01 12:57:00 +01:00
readwritefile.h util: extract {Read,Write}BinaryFile() to its own files 2021-03-01 12:56:56 +01:00
serfloat.cpp Add platform-independent float encoder/decoder 2021-05-24 16:04:44 -07:00
serfloat.h Add platform-independent float encoder/decoder 2021-05-24 16:04:44 -07:00
settings.cpp refactor: Block unsafe fs::path std::string conversion calls 2021-10-05 11:10:47 -04:00
settings.h Add <datadir>/settings.json persistent settings storage. 2020-07-11 05:41:12 -04:00
sock.cpp Cleanup headers after #20788 2021-09-11 10:47:02 +03:00
sock.h net: flag relevant Sock methods with [[nodiscard]] 2021-04-13 17:26:20 +02:00
spanparsing.cpp Add tr() descriptor (derivation only, no signing) 2021-05-24 12:14:16 -07:00
spanparsing.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
strencodings.cpp Merge bitcoin/bitcoin#23156: refactor: Remove unused ParsePrechecks and ParseDouble 2021-10-04 15:06:37 +02:00
strencodings.h doc: Fixup ToIntegral docs 2021-10-08 15:54:50 +02:00
string.cpp
string.h refactor: Move MakeUnorderedList into util/string.h to make it reusable 2021-08-06 22:08:24 +03:00
syscall_sandbox.cpp util: Add mincore and clone3 to syscall sandbox 2021-10-11 16:26:13 +02:00
syscall_sandbox.h Add syscall sandboxing (seccomp-bpf) 2021-10-01 13:51:10 +00:00
system.cpp refactor: Block unsafe fs::path std::string conversion calls 2021-10-05 11:10:47 -04:00
system.h scripted-diff: Rename overloaded int GetArg to GetIntArg 2021-09-27 06:57:20 -04:00
thread.cpp refactor: Make TraceThread a non-template free function 2021-04-25 12:28:44 +03:00
thread.h refactor: Make TraceThread a non-template free function 2021-04-25 12:28:44 +03:00
threadnames.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
threadnames.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
time.cpp scripted-diff: rename GetSystemTimeInSeconds to GetTimeSeconds 2021-05-31 15:11:18 +08:00
time.h scripted-diff: rename GetSystemTimeInSeconds to GetTimeSeconds 2021-05-31 15:11:18 +08:00
tokenpipe.cpp refactor: post Optional<> removal cleanups 2021-03-17 14:56:20 +08:00
tokenpipe.h util: Add RAII TokenPipe 2021-03-04 18:24:00 +01:00
trace.h tracing: add tracing framework 2020-12-07 11:55:51 +01:00
translation.h Add bilingual_str::clear() 2021-07-01 12:57:12 -04:00
types.h Add util/types.h with ALWAYS_FALSE template 2021-09-07 19:19:02 +02:00
ui_change_type.h wallet: Do not include server symbols 2020-06-27 11:39:09 -04:00
url.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
url.h scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
vector.h Add some general std::vector utility functions 2019-10-16 08:56:57 -07:00