aboutsummaryrefslogtreecommitdiff
path: root/build_msvc/libbitcoin_qt
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-04-03 06:50:10 +0800
committerMarcoFalke <falke.marco@gmail.com>2020-04-03 06:50:29 +0800
commitdce6f3b29b4197b8eea91f5919d56eb222ea8959 (patch)
tree2c86e42a8f8e91b51c7d9487dfc0cc7880336621 /build_msvc/libbitcoin_qt
parent0d71395848bbc2941862e7a0644f47212ec02e87 (diff)
parentf65c9ad40f2f5cdc581bdaf72e7dc68e9d7f7a80 (diff)
Merge #18383: refactor: Check for overflow when calculating sum of tx outputs
f65c9ad40f2f5cdc581bdaf72e7dc68e9d7f7a80 Check for overflow when calculating sum of outputs (Elichai Turkel) Pull request description: This was reported by practicalswift here #18046 The exact order of the if, is important, we first do `!MoneyRange(tx_out.nValue)` to make sure the amount is non-negative. and then `std::numeric_limits<CAmount>::max() - tx_out.nValue < nValueOut` checks that the addition cannot overflow (if we won't check that the amount is positive this check can also overflow! (by doing something like `max - -max`)) and only then we make sure that the some is also valid `!MoneyRange(nValueOut + tx_out.nValue)` if any of these conditions fail we throw. the overflowing logic: ``` a + b > max // we want to fail if a+b is more than the maximum -> will overflow b > max - a max - a < b ``` Closes: #18046 ACKs for top commit: MarcoFalke: ACK f65c9ad40f2f5cdc581bdaf72e7dc68e9d7f7a80, checked that clang with O2 produces identical binaries 💕 practicalswift: ACK f65c9ad40f2f5cdc581bdaf72e7dc68e9d7f7a80 instagibbs: utACK https://github.com/bitcoin/bitcoin/pull/18383/commits/f65c9ad40f2f5cdc581bdaf72e7dc68e9d7f7a80 vasild: ACK f65c9ad40f2f5cdc581bdaf72e7dc68e9d7f7a80 modulo `s/assert.h/cassert/` Tree-SHA512: 512d6cf4762f24c41cf9a38da486b17b19c634fa3f4efbdebfe6608779e96fc3014d5d2d29adb8001e113152c0217bbd5b3900ac4edc7b8abe77f82f36209e33
Diffstat (limited to 'build_msvc/libbitcoin_qt')
0 files changed, 0 insertions, 0 deletions