Repository navigation
Conversation
decode_cur_value_page_data() read the value page's uint32 row count, sized the not-null bitmap from it, and copied that many bytes out of the uncompressed page without checking against the page size. The bitmap index could also run past its end when the time page had more rows. Reject pages shorter than the count field plus bitmap, compute the bitmap size in 64-bit arithmetic so a count near UINT32_MAX cannot wrap to zero, and treat a row beyond a non-empty bitmap as corruption in the single-value decode loops. An empty bitmap still means every row is null. Also return the real error code from decode_cur_time_page_data()/decode_cur_value_page_data(), which || collapsed to 1.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The reader checks rounded-up bitmap capacity instead of the declared row count, allowing up to seven extra time rows to be accepted as padding.
1 open issue
What changed in this PR
This PR hardens the C++ aligned-value reader against malformed page row counts and preserves decoding error codes.
Changes:
- Validates row-count and bitmap sizes using overflow-safe arithmetic.
- Adds bitmap bounds checks to scalar and batch decoding paths.
- Adds valid-file and corrupted-row-count regression tests.
| File | Description |
|---|---|
cpp/test/reader/aligned_value_page_corruption_test.cc |
Adds valid-read, oversized-count, and overflow regression tests. |
cpp/src/reader/aligned_chunk_reader.h |
Adds a shared bitmap bounds-check helper. |
cpp/src/reader/aligned_chunk_reader.cc |
Validates page payloads, checks decoding bounds, and preserves error codes. |
Review effort: Balanced
Comment on lines
+256
to
+258
| return !value_page_col_notnull_bitmap_.empty() && | ||
| static_cast<size_t>(row / 8) >= | ||
| value_page_col_notnull_bitmap_.size(); |
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.

The aligned value page starts with a uint32 row count that sizes the not-null bitmap. Validate the count against the page length (64-bit arithmetic so a count near
UINT32_MAXcannot wrap), and treat a row index past a non-empty bitmap as corruption in the single-value decode loops. An empty bitmap still means every row is null. Also return the real error code fromdecode_cur_time_page_data()/decode_cur_value_page_data()instead of collapsing it to 1.Tests:
AlignedValuePageCorruptionTest.{ValidFileReadsEveryRow,OversizedRowCountIsRejected,RowCountThatWrapsBitmapSizeIsRejected}. Full C++ suite passes.