Skip to content

HLL: reject HLL_8 register values above 63 on deserialize - #599

Merged
proost merged 1 commit into
masterfrom
hll8-register-check
Nov 23, 2026
Merged

proost merged 1 commit into
masterfrom
hll8-register-check

Conversation

@leerho

@leerho leerho commented Nov 22, 2026

Copy link
Copy Markdown
Member

An HLL_8 register holds a value from 0 to 63, one byte per register. Both HllArray::newHll overloads (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 by mergeHll and processValue, 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_argument if 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

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>
@leerho
leerho requested review from proost and tisonkun November 22, 2026 20:50
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 45068042326

Coverage increased (+0.01%) to 97.093%

Details

  • Coverage increased (+0.01%) from the base build.
  • Patch coverage: 8 of 8 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 17473
Covered Lines: 16965
Line Coverage: 97.09%
Coverage Strength: 1883803.08 hits per line

💛 - Coveralls

@proost proost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@proost
proost merged commit e9fa2dd into master Nov 23, 2026
35 checks passed
@proost
proost deleted the hll8-register-check branch November 23, 2026 07:47
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.

3 participants