Skip to content

Commit 42bd4c7

Browse files
committed
[block encodings] Avoid fuzz blocking asserts in PartiallyDownloadedBlock
1 parent 1429f83 commit 42bd4c7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/blockencodings.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
5252
if (cmpctblock.shorttxids.size() + cmpctblock.prefilledtxn.size() > MAX_BLOCK_WEIGHT / MIN_SERIALIZABLE_TRANSACTION_WEIGHT)
5353
return READ_STATUS_INVALID;
5454

55-
assert(header.IsNull() && txn_available.empty());
55+
if (!header.IsNull() || !txn_available.empty()) return READ_STATUS_INVALID;
56+
5657
header = cmpctblock.header;
5758
txn_available.resize(cmpctblock.BlockTxCount());
5859

@@ -167,14 +168,18 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
167168
return READ_STATUS_OK;
168169
}
169170

170-
bool PartiallyDownloadedBlock::IsTxAvailable(size_t index) const {
171-
assert(!header.IsNull());
171+
bool PartiallyDownloadedBlock::IsTxAvailable(size_t index) const
172+
{
173+
if (header.IsNull()) return false;
174+
172175
assert(index < txn_available.size());
173176
return txn_available[index] != nullptr;
174177
}
175178

176-
ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing) {
177-
assert(!header.IsNull());
179+
ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing)
180+
{
181+
if (header.IsNull()) return READ_STATUS_INVALID;
182+
178183
uint256 hash = header.GetHash();
179184
block = header;
180185
block.vtx.resize(txn_available.size());

0 commit comments

Comments
 (0)