Skip to content

[C] Bound var data against the remaining buffer so a uint64 length cannot wrap the position - #1178

Open
slachiewicz wants to merge 1 commit into
aeron-io:masterfrom
slachiewicz:c-var-data-uint64-length-wrap
Open

slachiewicz wants to merge 1 commit into
aeron-io:masterfrom
slachiewicz:c-var-data-uint64-length-wrap

Conversation

@slachiewicz

Copy link
Copy Markdown
Contributor

With a uint64 var data length, the position + length passed to _set_sbe_position() can wrap and pass the bounds check, so get() copies past the buffer and the position moves backwards.

(), get_() and get__as_string_view() now compare the length with buffer_length - position, which cannot wrap, and return 0 or NULL with errno E100.

Part of #969.

Verified: CVarDataUint64LengthTest fails on master (heap-buffer-overflow in get_payload() under ASan) and passes here; sbe-tool checkstyle and test, cppbuild and cppbuild --debug-build --sanitise-build pass.

…nnot wrap the position.

Compare data_length with buffer_length - pos rather than passing
pos + data_length to set_sbe_position, which wraps for a uint64 length
and lets the position move backwards. 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