Skip to content

cmd/bbolt: reject overflowing page-item indexes#1204

Open
immanuwell wants to merge 1 commit into
etcd-io:mainfrom
immanuwell:fix-page-item-index-overflow
Open

cmd/bbolt: reject overflowing page-item indexes#1204
immanuwell wants to merge 1 commit into
etcd-io:mainfrom
immanuwell:fix-page-item-index-overflow

Conversation

@immanuwell

Copy link
Copy Markdown

page-item takes itemid as uint64 but then casts it to uint16. So 65536 wraps to 0 and prints the first item. tiny CLI footgun, but pretty real.

Repro:

bbolt page-item test.db <leaf-page-id> 65536

Before: succeeds and prints item 0, kinda yikes.
After: returns an itemid range error before reading the page.

Added a regression test for the wraparound case.

Tests:

go test ./cmd/bbolt/command -count=1
go test $(go list ./... | rg -v '/tests/failpoint$')

go test ./... still hits local failpoint setup failures here (failpoint: failpoint does not exist), unrelated to this change.

@k8s-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: immanuwell
Once this PR has been reviewed and has the lgtm label, please assign tjungblu for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Signed-off-by: immanuwell <pchpr.00@list.ru>
@immanuwell immanuwell force-pushed the fix-page-item-index-overflow branch from 8a6093a to 93cfe7d Compare May 21, 2026 09:49
@Elbehery

Copy link
Copy Markdown
Member

/ok-to-test

@Elbehery

Elbehery commented May 21, 2026

Copy link
Copy Markdown
Member

@immanuwell thanks for your contribution

Would you kindly share logs from the repro scenario above ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants