ORC-2161: [C++] UnionColumnReader should reject out-of-range union tags#2618
Closed
wgtmac wants to merge 1 commit intoapache:mainfrom
Closed
ORC-2161: [C++] UnionColumnReader should reject out-of-range union tags#2618wgtmac wants to merge 1 commit intoapache:mainfrom
wgtmac wants to merge 1 commit intoapache:mainfrom
Conversation
Member
Author
|
Thanks for the quick review, @ffacs! |
wgtmac
added a commit
that referenced
this pull request
May 7, 2026
### What changes were proposed in this pull request? This PR adds validation for C++ union tag values before they are used as child indexes. The change covers: - UnionColumnReader::skip - UnionColumnReader::nextInternal - UnionColumnPrinter::printRow If a malformed ORC file contains a union tag that is greater than or equal to the number of union children, the C++ reader/printer now throws ParseError instead of indexing out of bounds. ### Why are the changes needed? Union tags are decoded from the ORC data stream as byte values, but the valid range depends on the number of union children. Malformed input can contain a tag outside that range. The C++ reader previously trusted the tag value directly when indexing per-child state. This patch makes malformed union tags fail cleanly. ### How was this patch tested? Added C++ unit tests for a two-child union with invalid tag value 200, covering: - next - next with nulls - skip - ColumnPrinter ### Was this patch authored or co-authored using generative AI tooling? Generated-by: OpenAI Codex GPT-5. Closes #2618 from wgtmac/fix_union. Authored-by: Gang Wu <ustcwg@gmail.com> Signed-off-by: Gang Wu <ustcwg@gmail.com> (cherry picked from commit 3563ee5) Signed-off-by: Gang Wu <ustcwg@gmail.com>
wgtmac
added a commit
that referenced
this pull request
May 7, 2026
### What changes were proposed in this pull request? This PR adds validation for C++ union tag values before they are used as child indexes. The change covers: - UnionColumnReader::skip - UnionColumnReader::nextInternal - UnionColumnPrinter::printRow If a malformed ORC file contains a union tag that is greater than or equal to the number of union children, the C++ reader/printer now throws ParseError instead of indexing out of bounds. ### Why are the changes needed? Union tags are decoded from the ORC data stream as byte values, but the valid range depends on the number of union children. Malformed input can contain a tag outside that range. The C++ reader previously trusted the tag value directly when indexing per-child state. This patch makes malformed union tags fail cleanly. ### How was this patch tested? Added C++ unit tests for a two-child union with invalid tag value 200, covering: - next - next with nulls - skip - ColumnPrinter ### Was this patch authored or co-authored using generative AI tooling? Generated-by: OpenAI Codex GPT-5. Closes #2618 from wgtmac/fix_union. Authored-by: Gang Wu <ustcwg@gmail.com> Signed-off-by: Gang Wu <ustcwg@gmail.com> (cherry picked from commit 3563ee5) Signed-off-by: Gang Wu <ustcwg@gmail.com>
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.
What changes were proposed in this pull request?
This PR adds validation for C++ union tag values before they are used as child indexes.
The change covers:
If a malformed ORC file contains a union tag that is greater than or equal to the number of union children, the C++ reader/printer now throws ParseError instead of indexing out of bounds.
Why are the changes needed?
Union tags are decoded from the ORC data stream as byte values, but the valid range depends on the number of union children. Malformed input can contain a tag outside that range. The C++ reader previously trusted the tag value directly when indexing per-child state.
This patch makes malformed union tags fail cleanly.
How was this patch tested?
Added C++ unit tests for a two-child union with invalid tag value 200, covering:
Was this patch authored or co-authored using generative AI tooling?
Generated-by: OpenAI Codex GPT-5.