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 strncmp to not blindly read past string end #164

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

Johennes
Copy link
Contributor

Currently strcmp calls strncmp with usize::MAX which causes a panic due to the use of from_raw_parts.

thread 'main' panicked at library/core/src/panicking.rs:155:5:
unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`

This issue is triggered, for instance, when trying to create a keyboard widget.

This PR changes the implementation of strncmp to iterate over the strings up to the specified size but stopping on null bytes.

@rafaelcaricio rafaelcaricio merged commit 45cafea into lvgl:master Mar 26, 2024
1 check passed
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