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 1 commit into
aeron-io:masterfrom
slachiewicz:cpp-otf-var-data-length-wrap
Open

slachiewicz wants to merge 1 commit 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.

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