fix: accept full u8 range for STypeVar name length (JVM TypeSerializer parity) - #908
Open
mwaddip wants to merge 1 commit into
Open
fix: accept full u8 range for STypeVar name length (JVM TypeSerializer parity)#908mwaddip wants to merge 1 commit into
mwaddip wants to merge 1 commit into
Conversation
JVM `TypeSerializer.deserialize` reads the type-var name length via `getUByte()` (0..=255, no bound) then `new String(getBytes(len))`, so an empty name (length 0) and a 255-byte name both deserialize. sigma-rust bounded the name to `BoundedVec<u8, 1, 254>`, over-rejecting length 0 and 255 with a parse error -- a deserialization divergence from sigma-state. Use `Vec<u8>`: a `get_u8` length is inherently 0..=255, so no bound is meaningful. The UTF-8 validity check is retained. Adds a regression test on `STypeVar::sigma_parse` for length 0x00 and 0xff.
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.
The JVM
TypeSerializer.deserializereads the STypeVar name length viagetUByte()(0..=255, no bound) thennew String(getBytes(len)), so an empty name (length 0) and a 255-byte name both deserialize. sigma-rust bounded the name toBoundedVec<u8, 1, 254>, over-rejecting lengths 0 and 255 — a divergence from sigma-state 6.0.3 (the JVM accepts the tree, sigma-rust rejects it).Fix: store the name as
Vec<u8>; aget_u8length is inherently 0..=255, so no bound is meaningful. Adds a regression test onSTypeVar::sigma_parsefor length 0x00 and 0xff. Validated against the JVM oracle (sigma-state 6.0.3) by the conformance suite.Ref:
core/.../serialization/TypeSerializer.scala:202-206