AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 33 Bitcoin

util: Require integers for SaturatingAdd() and AdditionOverflow()

Public commit record

What the developer wrote

Authored by Hodlinator

73/100 · Adequate
util: Require integers for SaturatingAdd() and AdditionOverflow()

Previously we could fall back to using an unspecialized implementation of std::numeric_limits<T> which would compile as long as the numeric operators existed, but would return 0 for min() & max().
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This change tightens two low-level math helper functions so they only accept whole-number (integer) types. Previously, a non-integer type could slip through and silently produce wrong min/max values because the generic fallback for numeric limits returns 0. The patch prevents that misuse at compile time rather than relying on an internal check.

Recommended action

Treat as a defensive hardening improvement. Review all call sites of AdditionOverflow() and SaturatingAdd() to confirm no non-integer callers existed in prior releases, and include this change in routine backports for supported branches.

Security signals we found

01

Compile-time type constraint added to prevent non-integer numeric types from being used in overflow helpers

02

Removes reliance on std::numeric_limits generic fallback that returns 0 for min()/max()

03

Potential silent wrong-result path eliminated for AdditionOverflow and SaturatingAdd

Risk score

Why this scored 33/100

Our methodology →
Potential impact 8/30
Exploitability 5/25
Stealth signal 6/15
Affected reach 5/15
Confidence 6/10
Evidence quality 3/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.