Skip to content

Commit

Permalink
Fix Various Instances of Undefined Behaviour (#1198)
Browse files Browse the repository at this point in the history
* Fix UB in bls.

* Fix UB in CDKGSessionHandler::SleepBeforePhase.

* Fix UB in CQuorumBlockProcessor::GetCommitmentsFromBlock.
  • Loading branch information
sproxet authored and levonpetrosyan93 committed May 17, 2023
1 parent 1919d0b commit f492160
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/bls/bls.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CBLSWrapper
friend class CBLSPublicKey;
friend class CBLSSignature;

bool fLegacy;
bool fLegacy{fLegacyDefault};

protected:
ImplType impl;
Expand Down
3 changes: 2 additions & 1 deletion src/llmq/quorums_blockprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ bool CQuorumBlockProcessor::GetCommitmentsFromBlock(const CBlock& block, const C
return state.DoS(100, false, REJECT_INVALID, "bad-qc-dup");
}

ret.emplace((Consensus::LLMQType)qc.commitment.llmqType, std::move(qc.commitment));
auto llmqTypeTemp = (Consensus::LLMQType)qc.commitment.llmqType;
ret.emplace(llmqTypeTemp, std::move(qc.commitment));
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/llmq/quorums_dkgsessionhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ void CDKGSessionHandler::SleepBeforePhase(QuorumPhase curPhase,
phaseTime = 0;
}

int64_t sleepTime = (int64_t)(phaseTime * curSession->GetMyMemberIndex());
int64_t sleepTime = 0;
if (curSession->GetMyMemberIndex() != UINT64_MAX) sleepTime = (int64_t)(phaseTime * curSession->GetMyMemberIndex());
int64_t endTime = GetTimeMillis() + sleepTime;
while (GetTimeMillis() < endTime) {
if (stopRequested || ShutdownRequested()) {
Expand Down

0 comments on commit f492160

Please sign in to comment.