Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buffer overflow for bounded sequence example #444

Merged
merged 2 commits into from
Dec 9, 2024

Conversation

mxgrey
Copy link
Collaborator

@mxgrey mxgrey commented Dec 9, 2024

The example message VariousTypes has a string<=3 with a default value containing three characters which each have a length of two bytes in utf-8. This means the real length of the default value is 6 bytes even though the byte limit is <=3.

This PR changes the default value to be "aou" to be three bytes long. The other bounded string is a wide string (utf-16), so it can remain as-is.

To observe the problem, use $ cargo run in the message_demo example to see it return an error code if you use the main branch. Then use the branch of this PR and see that it does not return an error code.

Signed-off-by: Michael X. Grey <greyxmike@gmail.com>
Signed-off-by: Michael X. Grey <greyxmike@gmail.com>
@esteve
Copy link
Collaborator

esteve commented Dec 9, 2024

@mxgrey thanks!

@esteve esteve merged commit 7f53a4e into ros2-rust:main Dec 9, 2024
6 checks passed
@mxgrey mxgrey deleted the bounded_sequence_overflow branch December 9, 2024 10:50
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.

2 participants