Repository navigation
fix(parquet/variant): prevent metadata offset cursor overflow - #1290
Merged
zeroshade merged 1 commit intoSep 8, 2026
Merged
Conversation
zeroshade
approved these changes
Sep 8, 2026
zeroshade
left a comment
Member
There was a problem hiding this comment.
Confirmed the bug is real and the fix is correct. I reproduced the panic on current main with this PR's test (slice bounds out of range [255:1] at width_2/keys_126), so valid VARIANT metadata does fail today. The uint8 cursor wrapping at byte 256 is the root cause, and switching to an int cursor is safe because the existing valuesStart check already validates the full offset-table extent in uint64 arithmetic before the loop, keeping every slice in bounds. All 14 boundary subtests plus ./parquet/variant and ./arrow/extensions pass locally on the fix. Thanks for the tight, well-tested patch.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Arrow Go maintainer.
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.
Rationale for this change
Reading valid VARIANT metadata with 126 dictionary keys and two-byte offsets panics with
slice bounds out of range [255:1]. The metadata offset cursor inheritsuint8fromoffsetSz; both advancing the cursor and computing the slice end can wrap at byte 256. Three- and four-byte offset tables hit the same problem with even fewer keys.This also affects current main after #1063: validating the complete offset table does not prevent the cursor arithmetic from overflowing while reading that valid table.
What changes are included in this PR?
Use an
intoffset width and cursor for indexing the metadata buffer. Keep the wire-format width and existing metadata validation unchanged.Add synthetic valid-metadata tests immediately before, at, and after the failure boundary for two-, three-, and four-byte offsets, plus larger dictionaries. Check every decoded dictionary key. No external test data is required.
Are these changes tested?
go test ./parquet/variant -run TestMetadataOffsetTableCrossesByteBoundary -count=1reproduces the panic atwidth_2/keys_126.go test ./parquet/variant ./arrow/extensionspasses, including all 13 new boundary cases.Are there any user-facing changes?
Valid VARIANT dictionaries spanning byte 255 decode successfully instead of panicking. There are no public API or format changes.
Fixes #1291.