Repository navigation
[C++] Reject a wire blockLength shorter than the fixed fields of the acting version in the OTF decoder - #1179
Open
slachiewicz wants to merge 2 commits into
Open
slachiewicz wants to merge 2 commits into
slachiewicz wants to merge 2 commits into
Conversation
This was referenced Nov 14, 2026
slachiewicz
force-pushed
the
cpp-otf-block-length-lower-bound
branch
2 times, most recently
from
November 19, 2026 21:02
76cd7a9 to
edc60e0
Compare
…acting version in the OTF decoder. decode() and decodeGroups() reject the block before any field or onBeginGroup is dispatched. Fields newer than the acting version do not count, so older versions with shorter blocks still decode, and empty groups are not checked.
slachiewicz
force-pushed
the
cpp-otf-block-length-lower-bound
branch
from
November 27, 2026 15:17
edc60e0 to
3bb32d7
Compare
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 checks the buffer only against the blockLength from the wire, then hands listeners pointers at the schema field offsets. A frame whose message or group blockLength is shorter than the fixed fields gives listeners pointers past the buffer, and a group with blockLength 0 lets numInGroup entries be decoded from the same bytes, so the work no longer depends on the message size.
decode() and decodeGroups() now throw before dispatching any field or onBeginGroup when the blockLength is below the extent of the fields present at the acting version. Fields, and composite members, newer than the acting version do not count, and groups with numInGroup 0 are not checked. Listeners still receive offsets for fields newer than the acting version, as before, so they must check the version before reading them.
Part of #969.
Verified: OtfBlockLengthTest fails on master (2 of the 4 decode tests, plus a heap-buffer-overflow under ASan) and passes here, including a composite-member case; sbe-tool checkstyle and test, cppbuild and cppbuild --debug-build --sanitise-build pass.