Repository navigation
Tuple: check empty serial version 3 images strictly on deserialize - #601
Merged
Merged
Conversation
An empty compact tuple image was accepted whatever its other header bits held. Both deserializers now require the 8-byte form every current writer produces, as theta does: preamble longs 1, serial version 3, family 9, sketch type 1, unused byte 0, flags read-only, empty and compact with the reserved bits clear. The ordered flag and the seed hash are ignored. Serial version 1 images are unchanged. The mask and test values match Java CompactTupleSketch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Coverage Report for CI Build 45068050363Coverage increased (+0.01%) to 97.094%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 empty compact tuple image was accepted whatever its other header bits held; only the seed hash check was skipped. Theta has checked empty images strictly since #543. This does the same for
compact_tuple_sketch::deserialize, both the stream and the bytes overloads.For an empty serial version 3 image, the first 8 bytes must match the form every current writer produces. The mask is 0x0000EFFFFFFFFFFF and the required value 0x00000E0001090301: preamble longs 1, serial version 3, family 9, sketch type 1, unused byte 0, and the read-only, empty and compact flags set with the big-endian and reserved bits clear. The ordered flag is ignored, since older Java wrote empty images with flags 0x0e, and so is the seed hash, which writers set to 0 or the seed hash. Serial version 1 images are unchanged. The values match apache/datasketches-java#813.
Test, "tuple sketch: deserialize checks empty images strictly", from bytes and from a stream: C++ and older Java flags, any seed hash, and serial version 1 are accepted; preamble longs 2, the legacy sketch type 5, a non-zero unused byte, a missing read-only or compact flag, and the big-endian or a reserved flag set are rejected. It fails on master. All tuple tests pass under ASan and UBSan, and all 32 tuple_int snapshots in datasketches-tck (C++, Go, Java and Rust, including the Java n0 image with flags 0x0e and the Go n0 image with seed hash 0x93cc) still read.
🤖 Generated with Claude Code