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

lib: cbprintf: fix mishandling of precision string output #30665

Merged
merged 1 commit into from
Dec 18, 2020

Conversation

pabigot
Copy link
Collaborator

@pabigot pabigot commented Dec 11, 2020

If a precision flag is included for s formatting that bounds the maximum output length, so we need to use strnlen rather than strlen to get the amount of data to emit. With that flag we can't expect there to be a terminating NUL following the text to print.

Also fix handling of an empty precision, which should behave as if a precision of zero was provided.

@pabigot pabigot requested a review from npitre December 11, 2020 19:53
@github-actions github-actions bot added the area: Tests Issues related to a particular existing or missing test label Dec 11, 2020
If a precision flag is included for s formatting that bounds the
maximum output length, so we need to use strnlen rather than strlen to
get the amount of data to emit.  With that flag we can't expect there
to be a terminating NUL following the text to print.

Also fix handling of an empty precision, which should behave as if a
precision of zero was provided.

Signed-off-by: Peter Bigot <[email protected]>
@nashif nashif merged commit 5376223 into zephyrproject-rtos:master Dec 18, 2020
@pabigot pabigot deleted the nordic/20201211c branch January 11, 2021 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Tests Issues related to a particular existing or missing test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants