Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Various Instances of Undefined Behaviour #1198

Merged
merged 3 commits into from
Dec 15, 2022
Merged

Conversation

ghost
Copy link

@ghost ghost commented Jul 30, 2022

PR intention

This fixes several instances of UB.

Code changes brief

  • CQuorumBlockProcessor::GetCommitmentsFromBlock - std::move() was used incorrectly, leading to a use after free issue.
  • bls - An uninitialised boolean value is read.
  • CDKGSessionHandler::SleepBeforePhase - An invalid implicit cast from UINT64_MAX to double is performed in some cases.

@ghost ghost requested a review from psolstice July 30, 2022 11:11
@lgtm-com
Copy link

lgtm-com bot commented Jul 30, 2022

This pull request fixes 4 alerts when merging cf2b38b into 1e9bad8 - view on LGTM.com

fixed alerts:

  • 4 for Unused static function

@ghost ghost changed the title Fix UB in CQuorumBlockProcessor::GetCommitmentsFromBlock. Fix Various Instances of Undefined Behaviour Jul 31, 2022
@lgtm-com
Copy link

lgtm-com bot commented Jul 31, 2022

This pull request fixes 2 alerts when merging 3546005 into 1e9bad8 - view on LGTM.com

fixed alerts:

  • 2 for Unused static function

src/llmq/quorums_blockprocessor.cpp Show resolved Hide resolved
src/bls/bls.h Outdated Show resolved Hide resolved
@@ -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 temp = (Consensus::LLMQType) qc.commitment.llmqType;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't name variable temp please. llmqType is much better name

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use of the name temp is an indicator that the variable is semantically required. Can document in a comment instead if that's preferable.

@lgtm-com
Copy link

lgtm-com bot commented Dec 6, 2022

This pull request introduces 2 alerts when merging 40ce1d2 into bd9190d - view on LGTM.com

new alerts:

  • 2 for Unused static function

Heads-up: LGTM.com's PR analysis will be disabled on the 5th of December, and LGTM.com will be shut down ⏻ completely on the 16th of December 2022. Please enable GitHub code scanning, which uses the same CodeQL engine ⚙️ that powers LGTM.com. For more information, please check out our post on the GitHub blog.

@reubenyap reubenyap merged commit 396f8ef into master Dec 15, 2022
@reubenyap reubenyap deleted the quorum-ub-fix branch December 15, 2022 06:30
levonpetrosyan93 pushed a commit that referenced this pull request May 17, 2023
* Fix UB in bls.

* Fix UB in CDKGSessionHandler::SleepBeforePhase.

* Fix UB in CQuorumBlockProcessor::GetCommitmentsFromBlock.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants