Repository navigation
[Java] Check var-data length and group blockLength in the OTF decoder - #1154
Draft
slachiewicz wants to merge 3 commits into
Draft
slachiewicz wants to merge 3 commits into
slachiewicz wants to merge 3 commits into
Conversation
slachiewicz
force-pushed
the
java-otf-wire-length-checks
branch
2 times, most recently
from
November 19, 2026 21:00
cc56604 to
9fdae95
Compare
OtfMessageDecoder rejects a var-data length past the buffer and a group blockLength below the non-constant fields of the acting version, and JsonTokenListener checks the length before it allocates.
slachiewicz
force-pushed
the
java-otf-wire-length-checks
branch
from
November 27, 2026 15:17
9fdae95 to
3d08c88
Compare
slachiewicz
marked this pull request as draft
November 27, 2026 18:39
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.
OtfMessageDecoder passed the wire var-data length straight to the listener, and JsonTokenListener allocated a byte[] of that length before reading. A frame whose length prefix runs past the buffer therefore made JsonPrinter allocate up to 2 GB, or fail with OutOfMemoryError. The decoder also accepted a group blockLength of 0, which lets nested group headers expand the JSON output without bound.
The decoder now throws IndexOutOfBoundsException for an out-of-range var-data length, and for a group blockLength below the non-constant fields present at the acting version (composite members added in a later version do not count). JsonTokenListener checks the length itself before allocating.
Part of #969.
Verified: five of the new JsonPrinterTest cases fail on master (OutOfMemoryError, out-of-bounds read, accepted short block) and all pass here; sbe-tool checkstyle, tests, verifyJavaIrCodecsInSync and sbe-samples check pass.