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

snprintf truncate behavior by default #256

Merged
merged 6 commits into from
Jan 13, 2024
Merged

Conversation

charlesnicholson
Copy link
Owner

@charlesnicholson charlesnicholson commented Jan 13, 2024

npf_snprintf and npf_vsnprintf were incorrectly allowing strings to be non-terminated unless the NANOPRINTF_SNPRINTF_SAFE_TRIM_STRING_ON_OVERFLOW flag was specified. But, these functions should never allow unterminated strings; that's what the n is for.

This PR makes ..._TRIM_STRING_... the default behavior for npf_snprintf and npf_vsnprintf.

@charlesnicholson charlesnicholson changed the title wip snprintf truncating by default Jan 13, 2024
@charlesnicholson charlesnicholson marked this pull request as ready for review January 13, 2024 20:58
@charlesnicholson charlesnicholson changed the title snprintf truncating by default snprintf truncate behavior by default Jan 13, 2024
@charlesnicholson
Copy link
Owner Author

From the conversation in #251

@charlesnicholson charlesnicholson merged commit 64333b3 into main Jan 13, 2024
22 checks passed
@charlesnicholson charlesnicholson deleted the last-byte-of-buffer branch January 13, 2024 22:19
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.

1 participant