Skip to content

Commit e23a658

Browse files
Merge dashpay#6789: fix: avoid possible nullptr for unknown hash of qc after LookupBlockIndex
3b9e061 fix: handle possible nullptr in InitNewQuorum (Konstantin Akimov) c7890b7 fix: avoid possible nullptr for unknown hash of qc after LookupBlockIndex (Konstantin Akimov) Pull request description: ## Issue being fixed or feature implemented Follow-up for dashpay#6692; discovered possible nullptr usage after looking for non-existing block ## What was done? Added extra check for nullptr in 3 missing places in dash specific code: - CDKGSessionHandler::HandleDKGRound - CQuorumBlockProcessor::ProcessBlock - CQuorumBlockProcessor::ProcessCommitment ## How Has This Been Tested? N/A ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: utACK 3b9e061 Tree-SHA512: 3e5fa925250efa0e272c25f39d833c8fd1e51f1b9a338a63e8940dadfb91c61933eb48196f588621fdda3106fb887bd311dd01c287549720adb6124503e26b79
2 parents 873dee0 + 3b9e061 commit e23a658

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/llmq/blockprocessor.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ bool CQuorumBlockProcessor::ProcessBlock(const CBlock& block, gsl::not_null<cons
219219
for (const auto& [_, qc] : qcs) {
220220
if (qc.IsNull()) continue;
221221
const auto* pQuorumBaseBlockIndex = m_chainstate.m_blockman.LookupBlockIndex(qc.quorumHash);
222+
if (pQuorumBaseBlockIndex == nullptr) {
223+
LogPrint(BCLog::LLMQ, "[ProcessBlock] h[%d] unexpectedly failed due to no known pindex for hash[%s]\n",
224+
pindex->nHeight, qc.quorumHash.ToString());
225+
return false;
226+
}
222227
qc.VerifySignatureAsync(m_dmnman, m_qsnapman, pQuorumBaseBlockIndex, &queue_control);
223228
}
224229

@@ -334,6 +339,11 @@ bool CQuorumBlockProcessor::ProcessCommitment(int nHeight, const uint256& blockH
334339
}
335340

336341
const auto* pQuorumBaseBlockIndex = m_chainstate.m_blockman.LookupBlockIndex(qc.quorumHash);
342+
if (pQuorumBaseBlockIndex == nullptr) {
343+
LogPrint(BCLog::LLMQ, "%s -- unexpectedly failed due to no known pindex for hash[%s]\n", __func__,
344+
qc.quorumHash.ToString());
345+
return false;
346+
}
337347

338348
// we don't validate signatures here; they already validated on previous step
339349
if (!qc.Verify(m_dmnman, m_qsnapman, pQuorumBaseBlockIndex, /*checksigs=*/false)) {

src/llmq/dkgsessionhandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ void CDKGSessionHandler::HandleDKGRound(CConnman& connman, PeerManager& peerman)
539539

540540
const CBlockIndex* pQuorumBaseBlockIndex = WITH_LOCK(::cs_main, return m_chainstate.m_blockman.LookupBlockIndex(curQuorumHash));
541541

542-
if (!InitNewQuorum(pQuorumBaseBlockIndex)) {
542+
if (!pQuorumBaseBlockIndex || !InitNewQuorum(pQuorumBaseBlockIndex)) {
543543
// should actually never happen
544544
WaitForNewQuorum(curQuorumHash);
545545
throw AbortPhaseException();

0 commit comments

Comments
 (0)