From 8869d634f09578387933f2522de2c9412e158fe9 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 12 Nov 2020 09:34:44 +0100 Subject: [PATCH] Merge #20372: Avoid signed integer overflow when loading a mempool.dat file with a malformed time field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ee11a412a537f62aa46e8862678ce2069a2df5b7 Avoid signed integer overflow when loading a mempool.dat file with a malformed time field (practicalswift) Pull request description: Avoid signed integer overflow when loading a `mempool.dat` file with a malformed time field. Avoid the following signed integer overflow: ``` $ xxd -p -r > mempool.dat-crash-1 < >, ArgsManager const&) src/init.cpp:762:33 #3 0x5618d2b92162 in AppInitMain(util::Ref const&, NodeContext&, interfaces::BlockAndHeaderTipInfo*)::$_14::operator()() const src/init.cpp:1881:9 ``` This PR was broken out from PR #20089. Hopefully this PR is trivial to review. Fixes a subset of #19278. ACKs for top commit: MarcoFalke: review ACK ee11a412a537f62aa46e8862678ce2069a2df5b7 Crypt-iQ: crACK ee11a412a537f62aa46e8862678ce2069a2df5b7 Tree-SHA512: 227ab95cd7d22f62f3191693b455eacfa8e36534961bee12c622fc9090957cfb29992eabafa74d806a336e03385aa8f98b7ce734f04b0b400e33aa187d353337 --- src/validation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validation.cpp b/src/validation.cpp index b9fbc4e8c7aec..711656ed4d519 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5496,7 +5496,7 @@ bool LoadMempool(CTxMemPool& pool, CChainState& active_chainstate) pool.PrioritiseTransaction(tx->GetHash(), amountdelta); } TxValidationState state; - if (nTime + nExpiryTimeout > nNow) { + if (nTime > nNow - nExpiryTimeout) { LOCK(cs_main); assert(std::addressof(::ChainstateActive()) == std::addressof(active_chainstate)); AcceptToMemoryPoolWithTime(chainparams, pool, active_chainstate, state, tx, nTime,