Skip to content

blockstorage: fix unsigned underflow in GetBlockFileInfo bounds check#294

Open
kwsantiago wants to merge 1 commit intobitcoinknots:29.x-knotsfrom
privkeyio:fix-getblockfileinfo-underflow
Open

blockstorage: fix unsigned underflow in GetBlockFileInfo bounds check#294
kwsantiago wants to merge 1 commit intobitcoinknots:29.x-knotsfrom
privkeyio:fix-getblockfileinfo-underflow

Conversation

@kwsantiago
Copy link
Copy Markdown

Summary

  • GetBlockFileInfo checks n > m_blockfile_info.size()-1 which wraps to SIZE_MAX when the vector is empty
  • .at(n) then throws out_of_range, crashing the node
  • Fix: use n >= m_blockfile_info.size() instead

Test plan

  • Unit tests (blockmanager_tests): pass

size()-1 wraps to SIZE_MAX when m_blockfile_info is empty, bypassing
the bounds check and crashing via out_of_range from .at(n).
@luke-jr luke-jr added the bug label Apr 3, 2026
Copy link
Copy Markdown
Collaborator

@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

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

utACK 1543c87

@luke-jr luke-jr added this to the 29.3 (2nd) milestone Apr 10, 2026
luke-jr pushed a commit that referenced this pull request Apr 13, 2026
size()-1 wraps to SIZE_MAX when m_blockfile_info is empty, bypassing
the bounds check and crashing via out_of_range from .at(n).

Github-Pull: #294
Rebased-From: 1543c87
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants