-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Conversation
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]>
There was a problem hiding this 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.
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.... |
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]>
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.