Skip to content

fix(parquet): prevent byte stream split decoder panic - #11136

Open
jaideeppyne wants to merge 1 commit into
apache:mainfrom
jaideeppyne:fix-byte-stream-split-value-count
Open

jaideeppyne wants to merge 1 commit into
apache:mainfrom
jaideeppyne:fix-byte-stream-split-value-count

Conversation

@jaideeppyne

Copy link
Copy Markdown
Contributor

Closes #11121.

BYTE_STREAM_SPLIT previously used the page header count as its decode bound while deriving stream stride from the encoded bytes. A malformed header could therefore drive join_streams_const past the end of the buffer.

This change derives the decoder value count from complete encoded values, rejects partial values and encoded counts larger than the declared page count, and leaves declared counts that include Parquet v1 nulls valid. Higher-level readers now return their existing insufficient-values error for truncated required pages instead of panicking.

Tests cover the reported declared-count mismatch, partial values, and impossible oversized buffers.

Validation:

  • cargo test -p parquet --lib
  • cargo clippy -p parquet --lib --all-features -- -D warnings
  • cargo +stable fmt --all -- --check
  • git diff --check

@github-actions github-actions Bot added the parquet Changes to the parquet crate label Sep 19, 2026
fn test_byte_stream_split_uses_encoded_value_count() {
let mut decoder = ByteStreamSplitDecoder::<DoubleType>::new();

decoder.set_data(Bytes::from(vec![0; 64]), 63).unwrap();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The decoder seems to silently ignore the num_values parameter here. I would expect it to return an error if data.len() is smaller than num_values * T::get_type_size().

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

Labels

parquet Changes to the parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Out-of-bounds index in the BYTE_STREAM_SPLIT decoder on a malformed page header

2 participants