Skip to content

[release-1.3] cmd/bbolt: reject out of range item ids in page-item - #1329

Merged
ahrtr merged 1 commit into
etcd-io:release-1.3from
arpitjain099:backport/page-item-itemid-1.3
Nov 11, 2026
Merged

ahrtr merged 1 commit into
etcd-io:release-1.3from
arpitjain099:backport/page-item-itemid-1.3

Conversation

@arpitjain099

Copy link
Copy Markdown
Contributor

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.

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>
@Elbehery

Copy link
Copy Markdown
Member

/retitle [release-1.3] cmd/bbolt: reject out of range item ids in page-item

@kubernetes-prow kubernetes-prow Bot changed the title cmd/bbolt: reject out of range item ids in page-item (backport of #1315) [release-1.3] cmd/bbolt: reject out of range item ids in page-item Nov 11, 2026
@Elbehery

Copy link
Copy Markdown
Member

/ok-to-test

@kubernetes-prow

Copy link
Copy Markdown

[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.

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

@ahrtr
ahrtr merged commit 4d16cc5 into etcd-io:release-1.3 Nov 11, 2026
37 checks passed
ahrtr pushed a commit that referenced this pull request Nov 11, 2026
Add the backport of #1315 under the CMD section of v1.3.13, v1.4.4 and
v1.5.1, linking each release to its own backport: #1329 for 1.3, #1328
for 1.4 and #1327 for 1.5.

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
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