mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-08 19:53:27 +01:00
Merge bitcoin/bitcoin#31391: util: Drop boost posix_time in ParseISO8601DateTime
faf70cc994Remove wallet::ParseISO8601DateTime, use ParseISO8601DateTime instead (MarcoFalke)2222aecd5futil: Implement ParseISO8601DateTime based on C++20 (MarcoFalke) Pull request description: `boost::posix_time` in `ParseISO8601DateTime` has many issues: * It parses random strings that are clearly invalid and returns a time value for them, see [1] below. * None of the separators `-`, or `:`, or `T`, or `Z` are validated. * It may crash when running under a hardened C++ library, see https://github.com/bitcoin/bitcoin/issues/28917. * It has been unmaintained for years, so reporting or fixing any issues will most likely be useless. * It pulls in a third-party dependency, when the functionality is already included in vanilla C++20. Fix all issues by replacing it with a simple helper function written in C++20. Fixes https://github.com/bitcoin/bitcoin/issues/28917. [1] The following patch passes on current master: ```diff diff --git a/src/wallet/test/rpc_util_tests.cpp b/src/wallet/test/rpc_util_tests.cpp index 32f6f5ab46..c1c94c7116 100644 --- a/src/wallet/test/rpc_util_tests.cpp +++ b/src/wallet/test/rpc_util_tests.cpp @@ -12,6 +12,14 @@ BOOST_AUTO_TEST_SUITE(wallet_util_tests) BOOST_AUTO_TEST_CASE(util_ParseISO8601DateTime) { + BOOST_CHECK_EQUAL(ParseISO8601DateTime("964296"), 242118028800); + BOOST_CHECK_EQUAL(ParseISO8601DateTime("244622"), 15023836800); + BOOST_CHECK_EQUAL(ParseISO8601DateTime("+INfINITy"), 9223372036854); + BOOST_CHECK_EQUAL(ParseISO8601DateTime("7000802 01"), 158734166400); + BOOST_CHECK_EQUAL(ParseISO8601DateTime("7469-2 +INfINITy"), 9223372036854); + BOOST_CHECK_EQUAL(ParseISO8601DateTime("maXimum-datE-time"), 253402300799); + BOOST_CHECK_EQUAL(ParseISO8601DateTime("577737 114maXimum-datE-time"), 253402300799); + BOOST_CHECK_EQUAL(ParseISO8601DateTime("1970-01-01T00:00:00Z"), 0); BOOST_CHECK_EQUAL(ParseISO8601DateTime("1960-01-01T00:00:00Z"), 0); BOOST_CHECK_EQUAL(ParseISO8601DateTime("2000-01-01T00:00:01Z"), 946684801); ``` ACKs for top commit: hebasto: ACKfaf70cc994, I have reviewed the code and it looks OK. dergoegge: utACKfaf70cc994Tree-SHA512: 9dd745a356d04acf6200e13a6af52c51a9e2a0eeccea110093ce5da147b3c669c0eda918e46db0164c081a78c8feae3fe557a4759bea18449a8ff2d090095931
This commit is contained in:
@@ -20,7 +20,7 @@ from lint_ignore_dirs import SHARED_EXCLUDED_SUBTREES
|
||||
EXCLUDED_DIRS = ["contrib/devtools/bitcoin-tidy/",
|
||||
] + SHARED_EXCLUDED_SUBTREES
|
||||
|
||||
EXPECTED_BOOST_INCLUDES = ["boost/date_time/posix_time/posix_time.hpp",
|
||||
EXPECTED_BOOST_INCLUDES = [
|
||||
"boost/multi_index/detail/hash_index_iterator.hpp",
|
||||
"boost/multi_index/hashed_index.hpp",
|
||||
"boost/multi_index/identity.hpp",
|
||||
|
||||
Reference in New Issue
Block a user