Skip to content

fix(parquet): return error for invalid DELTA_LENGTH_BYTE_ARRAY lengths - #12324

Merged
etseidl merged 3 commits into
apache:mainfrom
shashank11yadav:fix/12290-delta-length-negative
Nov 19, 2026
Merged

etseidl merged 3 commits into
apache:mainfrom
shashank11yadav:fix/12290-delta-length-negative

Conversation

@shashank11yadav

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Rationale for this change

A Parquet page encoded with DELTA_LENGTH_BYTE_ARRAY (including the suffix stream of DELTA_BYTE_ARRAY) whose lengths are negative, or add up to more bytes than the page holds, makes the reader panic instead of returning an error. A negative length gives an out-of-range offset in get, and a length past the end panics in Bytes::slice. Malformed input should return a ParquetError.

What changes are included in this PR?

  • DeltaLengthByteArrayDecoder::set_data in parquet/src/encodings/decoding.rs now checks the decoded lengths when the page is set. A negative length, a sum that overflows, or a sum greater than the data after the length stream returns an error.
  • DeltaByteArrayDecoder uses the same decoder for its suffixes, so it gets the same check.
  • Three tests in the module's mod tests cover a negative length, a length past the end of the data, and a negative suffix length.

get and skip are unchanged. The checks in set_data make their offsets valid.

Are these changes tested?

The three new tests fail without this change and pass with it. The decoding module tests, clippy with warnings denied, the rustfmt check, and the arrow-feature type check all passed on this commit.

Not run: the typos spell check, and the full parquet test suite. Only the decoding module tests were run.

Are there any significant user-facing changes?

No public API change. Malformed pages that used to panic now return a ParquetError.

AI usage disclosure

I used an AI coding assistant while preparing this change; I reviewed and tested all of it myself.

DeltaLengthByteArrayDecoder::set_data did not validate the decoded
lengths. A negative length or lengths summing past the end of the page
made get and skip panic. Reject both when the page is set, as the arrow
reader decoders already do. DeltaByteArrayDecoder uses the same decoder
for its suffixes and is fixed by the same check.
@boring-cyborg boring-cyborg Bot added the parquet parquet crate label Nov 18, 2026

@etseidl etseidl left a comment

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.

Thanks @shashank11yadav, this looks correct to me. Might be worth mentioning in skip() that the next_offset sum is safe due to the validation in set_data coupled with other checks on the total buffer length.

@shashank11yadav

Copy link
Copy Markdown
Contributor Author

Might be worth mentioning in skip() that the next_offset sum is safe

Thanks for the review. I added a one-line comment in skip() noting that set_data already checks the lengths are nonnegative and fit in the page, so the sum can't overflow (53e1e15).

@etseidl
etseidl enabled auto-merge November 19, 2026 18:35
@etseidl
etseidl added this pull request to the merge queue Nov 19, 2026
Merged via the queue into apache:main with commit ab3ae54 Nov 19, 2026
22 checks passed
@Jefffrey Jefffrey added the bug Squash those bugs label Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Squash those bugs parquet parquet crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parquet: DELTA_LENGTH_BYTE_ARRAY decoder panics on a negative length instead of returning an error

3 participants