Skip to content

Fix bounds checks in binary reads, page traversal, and LOB loading - #6

Merged
boykopovar merged 3 commits into
boykopovar:mainfrom
MinorGlitch:fix/parser-bounds
Nov 17, 2026
Merged

boykopovar merged 3 commits into
boykopovar:mainfrom
MinorGlitch:fix/parser-bounds

Conversation

@MinorGlitch

Copy link
Copy Markdown
Contributor

This adds missing bounds checks to binary field reads, page traversal, and LOB loading. The affected invalid inputs are rejected instead of allowing out-of-bounds access or silently returning truncated values.

  • Check that fixed-width fields fit within the supplied buffer, including offsets near SIZE_MAX.
  • Require complete 4096-byte pages and validate slot counts before calculating directory positions.
  • Reject truncated inline LOBs, invalid chained-LOB chunk indices and page sizes, and declared lengths exceeding database capacity.
  • Calculate LOB page counts without overflowing the declared length.

Existing behavior for valid data and skipping malformed row extents is preserved. Self-contained native regression tests use the existing CMake/CTest setup. No CI changes or new dependencies are included.

I haven't run the full Windows suite.

Reject truncated fields and offsets outside the supplied buffer before
accessing bytes. Use subtraction for the size check to avoid overflow.

Add regression tests for short buffers, boundary offsets, and valid values.
Require a complete page and reject slot counts that would wrap the slot
index. Check row extents without adding untrusted lengths.

Cover invalid page sizes and slot counts, valid rows and continuation
links, and the existing behavior of skipping malformed row extents.
Reject inline values shorter than their declared length. Check chained
LOB chunk indices and page sizes, and reject lengths beyond database
capacity. Calculate page counts without overflowing the length.

Add regression tests for truncated values, invalid bounds, and valid
inline and chained contents.
@boykopovar boykopovar closed this Nov 17, 2026
@boykopovar boykopovar reopened this Nov 17, 2026
@boykopovar
boykopovar merged commit 63da83c into boykopovar:main Nov 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants