Skip to content

[C++] Bound OTF var data against the remaining buffer so a uint64 length cannot wrap the index - #1180

Open
slachiewicz wants to merge 2 commits into
aeron-io:masterfrom
slachiewicz:cpp-otf-var-data-length-wrap
Open

slachiewicz wants to merge 2 commits into
aeron-io:masterfrom
slachiewicz:cpp-otf-var-data-length-wrap

Conversation

@slachiewicz

Copy link
Copy Markdown
Contributor

decodeData checked bufferIndex + dataLength > length, which wraps for a uint64 var data length, so onVarData received a length of 2^64-1 at the end of the buffer and decode() returned a wrapped size.

The check is now dataLength > length - bufferIndex, which cannot wrap.

Part of #969.

Verified: OtfVarDataLengthTest fails on master (no exception, onVarData called) and passes here; sbe-tool checkstyle and test, cppbuild and cppbuild --debug-build --sanitise-build pass.

@slachiewicz
slachiewicz force-pushed the cpp-otf-var-data-length-wrap branch 2 times, most recently from deedd61 to 479aaa6 Compare November 19, 2026 21:02
…gth cannot wrap the index.

decodeData compares dataLength with length - bufferIndex, which cannot
wrap, rather than bufferIndex + dataLength, which does for a uint64
length. Do not go back to the addition.
@slachiewicz
slachiewicz force-pushed the cpp-otf-var-data-length-wrap branch from 479aaa6 to 16d05f6 Compare November 27, 2026 15:17
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