Repository navigation
Conversation
…AY pages ByteArrayDecoderPlain::skip did not check value lengths against the page, so a corrupt length moved the offset past the end of the buffer and the next read underflowed `buf.len() - offset`. read also divided by max_remaining_values, which is 0 on a v2 page whose header claims every value is null. skip now returns the same EOF error as read, and read returns Ok(0) when there is nothing to read. ByteViewArrayDecoderPlain::skip had the same unchecked loop and gets the same check. Co-authored-by: Isaac <no-reply@databricks.com>
This branch has not been deployed
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.
Which issue does this PR close?
Rationale for this change
ByteArrayDecoderPlaincan panic on corrupt PLAINBYTE_ARRAYpages, and both panics can be reached fromParquetRecordBatchReader.skipmoves past the end of the page without an error. The nextreadon that page then underflowsbuf.len() - offset.readdivides bymax_remaining_values, which is 0 on a v2 page whose header claims every value is null.The issue has repro steps.
What changes are included in this PR?
ByteArrayDecoderPlain::skipchecks each value's end offset against the page, usingchecked_add, and returns the sameParquetError::EOF("eof decoding byte array")thatreadreturns. On error the offset stays at the start of the bad value.ByteArrayDecoderPlain::readreturnsOk(0)when there is nothing to read (to_read == 0), before it estimates the reservation. It already returnedOk(0)for that case. The column reader compares the count with the number of values the levels asked for, so a page that claims no values while the levels want one now fails with "insufficient values read from column" instead of panicking.ByteViewArrayDecoderPlain::skiphas the identical loop and gets the same check. It didn't panic, because the viewreadbounds-checks first, but on a corrupt pageskipreturnedOk.Are these changes tested?
Yes.
skippast the end of the page, for both plain decodersreadwith no remaining valuesreadandskip: a value longer than the page, au32::MAXlength, and a length prefix cut to 1-3 bytes. Each case checks forEOF, that earlier values are kept, and that the offset stays at the bad value.arrow_reader/tests/column_reader.rspatch bytes of a written file and read it withParquetRecordBatchReader. Both panicked before this change.Are there any significant user-facing changes?
No.