Fix OOB read on metadata IN filter path (size_t -> int) - #318
Open
stumpylog wants to merge 1 commit into
Open
Conversation
VEC0_METADATA_OPERATOR_IN declared `size_t metadataInIdx = -1`, which wraps to SIZE_MAX. The subsequent `if (metadataInIdx < 0)` not-found guard is dead code for an unsigned type, so a missing entry fell through to an out-of-bounds read indexing the metadata-IN array. The parallel path already uses `int`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
vec0's metadataIN (...)filter path (VEC0_METADATA_OPERATOR_INinvec0_metadata_filter_text) declares:size_tis unsigned, so this wraps toSIZE_MAX. The subsequent not-found guard:is dead code for an unsigned type — it can never fire. If the constraint lookup doesn't find a matching entry, execution falls through and indexes
aMetadataInwithSIZE_MAX, an out-of-bounds read. The parallelINhandling in the same file (vec0_filter, a few hundred lines down) already declares this asintfor the same reason — this is a case where the twoINcode paths drifted apart.Fix
Change
metadataInIdxtoint, matching the already-correct sibling path. The guard now does what it always looked like it did.Testing
Added
test_metadata_in_filtertotests/test-metadata.py, exercising alabel IN (...)metadata filter with a full round-trip on a smallvec0table.🤖 Generated with Claude Code