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

[0.18 backport] Fix HasValidFee potential overflow #864

Merged
merged 1 commit into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/confidential_validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ bool HasValidFee(const CTransaction& tx) {
if (fee == 0 || !MoneyRange(fee))
return false;
totalFee[tx.vout[i].nAsset.GetAsset()] += fee;
if (!MoneyRange(totalFee)) {
return false;
}
}
}
return MoneyRange(totalFee);
return true;
}

CAmountMap GetFeeMap(const CTransaction& tx) {
Expand Down
3 changes: 3 additions & 0 deletions src/consensus/tx_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins
return state.DoS(100, false, REJECT_INVALID, "bad-txns-in-ne-out", false, "value in != value out");
}
fee_map += GetFeeMap(tx);
if (!MoneyRange(fee_map)) {
return state.DoS(100, false, REJECT_INVALID, "bad-block-total-fee-outofrange");
}
} else {
const CAmount value_out = tx.GetValueOutMap()[CAsset()];
if (nValueIn < value_out) {
Expand Down