Skip to content

Conversation

practicalswift
Copy link
Contributor

@practicalswift practicalswift commented Apr 26, 2020

Add fuzzing harnesses for various classes/functions in policy/ (CBlockPolicyEstimator, IsRBFOptIn(…), etc.).

See doc/fuzzing.md for information on how to fuzz Bitcoin Core. Don't forget to contribute any coverage increasing inputs you find to the Bitcoin Core fuzzing corpus repo.

Happy fuzzing :)

@DrahtBot
Copy link
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

NODISCARD inline CTxMemPoolEntry ConsumeTxMemPoolEntry(FuzzedDataProvider& fuzzed_data_provider, const CTransaction& tx) noexcept
{
// Avoid:
// policy/feerate.cpp:28:34: runtime error: signed integer overflow: 34873208148477500 * 1000 cannot be represented in type 'long'
Copy link
Member

Choose a reason for hiding this comment

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

how is this possible? ConsumeMoney should be less than 34873208148477500

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you're misunderstanding what is happening here: note that it ConsumeMoney is always returning within the money bounds, but the calculation does not take place directly on that amount :)

See this example:

const CAmount fee_paid = 348732081484775;
assert(MoneyRange(fee_paid));
const size_t bytes = 10;
const CFeeRate fee_rate(fee_paid, bytes);
(void)fee_rate.GetFeePerK();
policy/feerate.cpp:28:34: runtime error: signed integer overflow: 34873208148477500 * 1000 cannot be represented in type 'long'

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

ACK

@practicalswift
Copy link
Contributor Author

Added a commit which clarifies how the signed integer overflow in CFeeRate::GetFeePerK() is avoided when fuzzing :)

@maflcko maflcko merged commit ef8ef31 into bitcoin:master Apr 30, 2020
decryp2kanon added a commit to sugarchain-project/yumekawa that referenced this pull request Oct 20, 2020
BTC has error too
// policy/feerate.cpp:28:34: runtime error: signed integer overflow: 34873208148477500 * 1000 cannot be represented in type 'long'
bitcoin/bitcoin#18775
@practicalswift practicalswift deleted the fuzzers-policy branch April 10, 2021 19:41
kwvg added a commit to kwvg/dash that referenced this pull request Aug 11, 2022
…ons in policy/ (CBlockPolicyEstimator, IsRBFOptIn(…), etc.)
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants