HomePhabricator

[64-bit ints] Add overflow checks to CScriptNum for +, -, +=, -=

Description

[64-bit ints] Add overflow checks to CScriptNum for +, -, +=, -=

Summary:
Check for overflows in these functions:

  • operator+
  • operator-
  • operator+=
  • operator-=

Note: operator- (negation), operator/ and operator% don't need overflow checks, because by design these can never overflow, as we exclude std::numeric_limits<int64_t>::min() from the valid script integer range.

Depends on D17000 and D16997.

Test Plan: ninja check

Reviewers: Fabien, #bitcoin_abc

Reviewed By: Fabien, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D17001

Details

Provenance
tobias_ruckAuthored on Dec 6 2024, 10:51
tobias_ruckPushed on Aug 1 2025, 19:11
Reviewer
Restricted Project
Differential Revision
D17001: [64-bit ints] Add overflow checks to CScriptNum for +, -, +=, -=
Parents
rABCfe0b9d2657b7: [64-bit ints] Refactor `CScriptNum` to require setting `nMaxNumSize`
Branches
Unknown
Tags
Unknown