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

common: fix over-allocation in merkle tree creation.

Public commit record

What the developer wrote

Authored by Rusty Russell

73/100 · Adequate
common: fix over-allocation in merkle tree creation.

If we have 5 fields, ilog64(5) is 3, and (1 << 3) is 8. Adding one
made it 16.

In fact, since ilog64(4) is also 3, we should *subtract one*, but
this handles 0 more neatly (ilog64(0) is defined to return 0, as
a special case).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a simple math bug that caused the program to reserve up to twice as much temporary memory as needed when building a special data structure (a Merkle tree) used in BOLT 12 offers. The bug did not corrupt data or expose secrets; it only wasted memory. The patch removes an unnecessary '+1' in the allocation size calculation.

Recommended action

No urgent action required. Treat as a routine cleanup/optimization. If backporting, include it with other BOLT 12 fixes but do not prioritize as a security patch.

Security signals we found

01

Over-allocation in temporary array

02

No out-of-bounds access or use-after-free pattern

03

No attacker-controlled size leading to overflow

04

No secret-dependent branch or memory disclosure

Risk score

Why this scored 26/100

Our methodology →
Potential impact 5/30
Exploitability 2/25
Stealth signal 3/15
Affected reach 4/15
Confidence 8/10
Evidence quality 4/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.