forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge bitcoin#31391: util: Drop boost posix_time in ParseISO8601DateTime
faf70cc Remove wallet::ParseISO8601DateTime, use ParseISO8601DateTime instead (MarcoFalke) 2222aec util: 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 bitcoin#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 bitcoin#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: ACK faf70cc, I have reviewed the code and it looks OK. dergoegge: utACK faf70cc Tree-SHA512: 9dd745a356d04acf6200e13a6af52c51a9e2a0eeccea110093ce5da147b3c669c0eda918e46db0164c081a78c8feae3fe557a4759bea18449a8ff2d090095931
- Loading branch information
Showing
14 changed files
with
94 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters