Skip to content

[C++] Reject a wire blockLength shorter than the fixed fields of the acting version in the OTF decoder - #1179

Open
slachiewicz wants to merge 1 commit into
aeron-io:masterfrom
slachiewicz:cpp-otf-block-length-lower-bound
Open

slachiewicz wants to merge 1 commit into
aeron-io:masterfrom
slachiewicz:cpp-otf-block-length-lower-bound

Conversation

@slachiewicz

Copy link
Copy Markdown
Contributor

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.

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