Skip to content

[C++] Reject a wire blockLength shorter than the fixed fields of the acting version - #1176

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

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

Conversation

@slachiewicz

Copy link
Copy Markdown
Contributor

Generated decoders take the message and group blockLength from the wire and read fixed fields at their schema offsets, so a frame whose blockLength is shorter than those fields, with the buffer ending accordingly, makes the field accessors read past the buffer.

wrapForDecode, the decoding constructor and the group wrapForDecode now reject a blockLength below the extent of the fields present at the acting version (E100 for messages, E108 for groups). The minimum is generated per version, so blocks from older schema versions still decode, including composites that gained a member in a later version, and a group with numInGroup 0 is not checked. A decoder that passes its own schema version as the acting version, rather than the version from the header, now rejects shorter blocks from older senders. The helper that computes the minimum lives in Generators so the C generator can share it.

Part of #969.

Verified: WireBlockLengthTest fails on master (3 of 5 tests, no exception thrown) and passes here, and MinBlockLengthExpressionTest covers the composite case; sbe-tool checkstyle and test, cppbuild and cppbuild --debug-build --sanitise-build pass.

…acting version.

The message and group decoders must not accept a blockLength below the
extent of the fields present at the acting version. The minimum is per
version because older versions have shorter blocks, so do not replace it
with sbeBlockLength(). 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