Repository navigation
HLL: reject HLL_8 register values above 63 on deserialize - #599
Merged
Merged
Conversation
An HLL_8 register holds a value from 0 to 63, but both deserializers copied the register bytes as they were, so a corrupt image could carry a larger value into estimates and unions. Reject such images, as Go, Rust and Java do. Sketches written by this library are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Coverage Report for CI Build 45068042326Coverage increased (+0.01%) to 97.093%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
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.
An HLL_8 register holds a value from 0 to 63, one byte per register. Both
HllArray::newHlloverloads (bytes and stream) copied the register bytes from the image as they were, so a corrupt image could carry a value above 63 into the sketch. Such a value is kept bymergeHllandprocessValue, is seen masked to 6 bits by the iterator, and stops that register from being raised by later updates.Both deserializers now throw
std::invalid_argumentif any HLL_8 register is above 63. The bytes overload checks before it creates the sketch. Go and Rust already reject these images, and apache/datasketches-java#814 does the same for Java. Sketches written by this library are unchanged.Test, "hll array: rejects an HLL_8 register above 63": the last register of an HLL-mode image set to 64, 200 or 255 is rejected from bytes and from a stream, for compact and updatable images; 63 is still accepted. It fails on master. All HLL tests pass under ASan and UBSan.
🤖 Generated with Claude Code