Repository navigation
[Java] Reject a message blockLength shorter than the fields of the acting version - #1183
Open
slachiewicz wants to merge 1 commit into
Open
slachiewicz wants to merge 1 commit into
slachiewicz wants to merge 1 commit into
Conversation
…ting version. The generated decoder wrap and OtfMessageDecoder only checked group block lengths. The minimum is per acting version, so do not replace it with BLOCK_LENGTH.
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 generated Java decoder wrap and OtfMessageDecoder.decode() only checked group block lengths, so a message whose root blockLength was shorter than its fixed fields was accepted and the fields were read from the bytes that follow. Both now throw IndexOutOfBoundsException, matching the C, C++ and C++ OTF decoders (#1176, #1177, #1179).
The minimum is computed per acting version: constant fields and fields newer than the acting version do not count, and neither do composite members newer than the acting version. A message from an older version with a shorter block still decodes. SchemaExtensionTest passed block lengths that were too short for the version under test; those three calls now pass the real lengths. A caller that wraps a decoder with a block length shorter than the acting version's fields now gets an exception instead of fields read from the following bytes.
Part of #969.
Verified: the new MessageBlockLengthTest fails 12 of 21 on master and passes here; sbe-tool checkstyle and test, verifyJavaIrCodecsInSync and sbe-samples:check pass.