Validate header fields and sizes when deserializing CPC, Count-Min, Theta (v4) and VarOpt - #538
Merged
Merged
Conversation
…heta and VarOpt - var_opt_union: require the full non-empty preamble before reading it. - count_min_sketch: include the preamble in the deserialized size check; compute num_buckets * num_hashes in 64 bits. - compact theta, serial version 4: compute the packed data size in 64 bits, and require entry bits in [1, 63] and num entries bytes in [1, 4], for both byte and stream deserialization. - cpc_sketch: validate lg_k, num_coupons and the number of table entries; bound decoding by the number of compressed words; require decoded rows and columns to be in range; check the input size before allocating. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Coverage Report for CI Build 37163065438Coverage increased (+0.03%) to 82.375%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
AlexanderSaydakov
approved these changes
Oct 4, 2026
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.
Following #536, this applies the same kind of input validation to more deserializers, so that malformed or truncated serialized sketches are rejected with an exception before any field is read or used:
lg_k, the coupon count and the number of table entries; bound decoding by the size of the compressed data; check decoded row and column indices; check the input size before allocating.Each change has regression tests. All test suites pass, including under AddressSanitizer.
This is the last change planned for 5.3.0.
🤖 Generated with Claude Code