Skip to content

zephyr: Add zero-len check for utf8_trunc #74949

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

Merged
merged 2 commits into from
Jun 27, 2024

Conversation

Thalley
Copy link
Collaborator

@Thalley Thalley commented Jun 25, 2024

The function did not check if the provided string had a zero length before starting to truncate, which meant that last_byte_p could possible have pointed to the value before the string.

The function did not check if the provided string had a zero
length before starting to truncate, which meant that last_byte_p
could possible have pointed to the value before the string.

Signed-off-by: Emil Gydesen <[email protected]>
jhedberg
jhedberg previously approved these changes Jun 25, 2024
Copy link
Member

@jhedberg jhedberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but seems like we should probably also add some unit tests for this API.

@Thalley
Copy link
Collaborator Author

Thalley commented Jun 25, 2024

Looks good, but seems like we should probably also add some unit tests for this API.

Indeed; how do they fit in with the feature freeze? I can add the tests no problem, but should they be part of this PR? Or a separate PR? I guess we can't merge them during the freeze?

@nashif nashif added this to the v3.7.0 milestone Jun 25, 2024
@nashif
Copy link
Member

nashif commented Jun 25, 2024

Indeed; how do they fit in with the feature freeze? I can add the tests no problem, but should they be part of this PR? Or a separate PR? I guess we can't merge them during the freeze?

adding tests is fine, especially when it tests for something that was a bug....

@Thalley
Copy link
Collaborator Author

Thalley commented Jun 25, 2024

Added unit tests

The two functions did not have unit tests, and at least one
issue with input validation have been indentified and fixed
prior to these.

Signed-off-by: Emil Gydesen <[email protected]>
@nashif nashif merged commit 1fc67d2 into zephyrproject-rtos:main Jun 27, 2024
22 checks passed
@Thalley Thalley deleted the utf_len_fix branch June 27, 2024 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants