Skip to content

[Java] Reject a message blockLength shorter than the fields of the acting version - #1183

Open
slachiewicz wants to merge 1 commit into
aeron-io:masterfrom
slachiewicz:java-message-block-length-check
Open

slachiewicz wants to merge 1 commit into
aeron-io:masterfrom
slachiewicz:java-message-block-length-check

Conversation

@slachiewicz

Copy link
Copy Markdown
Contributor

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.

…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.
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.

1 participant