diff options
author | dergoegge <n.goeggi@gmail.com> | 2023-01-16 16:14:16 +0100 |
---|---|---|
committer | dergoegge <n.goeggi@gmail.com> | 2023-01-23 17:18:35 +0100 |
commit | 42bd4c746824e3b2adf2c696cf4a705fa43d1fa8 (patch) | |
tree | 22080391aee654951827646c6b544e8854d8ad82 /src/blockencodings.cpp | |
parent | 1429f8377017c0029cb87c4d355c37b796432611 (diff) |
[block encodings] Avoid fuzz blocking asserts in PartiallyDownloadedBlock
Diffstat (limited to 'src/blockencodings.cpp')
-rw-r--r-- | src/blockencodings.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/blockencodings.cpp b/src/blockencodings.cpp index c83e893c0e..0d5575e5d5 100644 --- a/src/blockencodings.cpp +++ b/src/blockencodings.cpp @@ -52,7 +52,8 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c if (cmpctblock.shorttxids.size() + cmpctblock.prefilledtxn.size() > MAX_BLOCK_WEIGHT / MIN_SERIALIZABLE_TRANSACTION_WEIGHT) return READ_STATUS_INVALID; - assert(header.IsNull() && txn_available.empty()); + if (!header.IsNull() || !txn_available.empty()) return READ_STATUS_INVALID; + header = cmpctblock.header; txn_available.resize(cmpctblock.BlockTxCount()); @@ -167,14 +168,18 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c return READ_STATUS_OK; } -bool PartiallyDownloadedBlock::IsTxAvailable(size_t index) const { - assert(!header.IsNull()); +bool PartiallyDownloadedBlock::IsTxAvailable(size_t index) const +{ + if (header.IsNull()) return false; + assert(index < txn_available.size()); return txn_available[index] != nullptr; } -ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing) { - assert(!header.IsNull()); +ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing) +{ + if (header.IsNull()) return READ_STATUS_INVALID; + uint256 hash = header.GetHash(); block = header; block.vtx.resize(txn_available.size()); |