Repository navigation
[release-1.3] cmd/bbolt: reject out of range item ids in page-item - #1329
Merged
ahrtr merged 1 commit intoNov 11, 2026
Merged
Conversation
The item id is parsed as a uint64 and then narrowed to uint16 at both call sites, so the bounds check in leafPageElement only sees the low 16 bits. An id congruent to a valid index modulo 65536 prints that item and exits 0, and an id congruent to an out of range index is reported back with the truncated number rather than the one given. Keep the id a uint64 until it has been compared against the page count, and narrow it only afterwards. Cherry-picked from etcd-io#1315 (f3dbd58). Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
This was referenced Nov 11, 2026
Member
|
/retitle [release-1.3] cmd/bbolt: reject out of range item ids in page-item |
Member
|
/ok-to-test |
Elbehery
approved these changes
Nov 11, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: arpitjain099, Elbehery The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
ahrtr
pushed a commit
that referenced
this pull request
Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #1315 to release-1.3 as requested.
The page-item command narrows the item id from uint64 to uint16 before the bounds check, so leafPageElement only compares the low 16 bits. An id congruent to a valid index modulo 65536 prints that item and exits 0, and one congruent to an out of range index reports the truncated number instead of the id that was typed. The id now stays a uint64 until after the page-count check and is narrowed only for the final LeafPageElement lookup.
The command lives in cmd/bbolt/main.go on this branch and uses the older guts_cli page helpers, so I applied the fix by hand and added TestPageItemCommand_ItemIDOutOfRange in this branch's main_test.go style. The test fails before the change and passes after, and go test ./cmd/bbolt/... is green. Changelog entries for 1.3, 1.4 and 1.5 are in a separate PR against main, following the pattern used for #1297/#1296/#1295.
AI assistance was used for implementation and review.