Skip to content

fix(chain): prevent integer overflow in SpkIterator::new_with_range#2180

Merged
evanlinjin merged 1 commit intobitcoindevkit:masterfrom
tnull:2026-04-fix-spk-iterator-overflow
Apr 23, 2026
Merged

fix(chain): prevent integer overflow in SpkIterator::new_with_range#2180
evanlinjin merged 1 commit intobitcoindevkit:masterfrom
tnull:2026-04-fix-spk-iterator-overflow

Conversation

@tnull
Copy link
Copy Markdown
Contributor

@tnull tnull commented Apr 16, 2026

Description

The start and end bound calculations used unchecked addition which
overflows when given u32::MAX, causing the iterator to silently produce
wrong results (e.g., an empty iterator for 0..=u32::MAX in release
mode). Use saturating_add to handle the boundary correctly.

Checklists

All Submissions:

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

Copy link
Copy Markdown
Member

@evanlinjin evanlinjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK b5786dd

Copy link
Copy Markdown
Member

@luisschwab luisschwab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK b5786dd

@luisschwab luisschwab moved this to Needs Review in BDK Chain Apr 19, 2026
@evanlinjin evanlinjin added this to the Chain 0.24.0 milestone Apr 23, 2026
The start and end bound calculations used unchecked addition which
overflows when given `u32::MAX`, causing the iterator to silently produce
wrong results (e.g., an empty iterator for `0..=u32::MAX` in release
mode). Use `saturating_add` to handle the boundary correctly.

Co-Authored-By: HAL 9000
Signed-off-by: Elias Rohrer <dev@tnull.de>
@evanlinjin evanlinjin force-pushed the 2026-04-fix-spk-iterator-overflow branch from b5786dd to b340e96 Compare April 23, 2026 15:35
Copy link
Copy Markdown
Member

@luisschwab luisschwab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK b340e96

@evanlinjin evanlinjin merged commit 10d9333 into bitcoindevkit:master Apr 23, 2026
18 checks passed
@github-project-automation github-project-automation Bot moved this from Needs Review to Done in BDK Chain Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants