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

mprintf: terminate snprintf output on windows #15997

Closed
wants to merge 1 commit into from

Conversation

jay
Copy link
Member

@jay jay commented Jan 14, 2025

  • Null terminate the end of the snprintf output buffer on Windows.

Old versions of the Windows CRT (which are often found on later versions of Windows) do not terminate the snprintf output buffer if the output reaches the max size.

This is a follow-up to 7e32f65 which made the same change but limited it to mingw, however it is a CRT version issue irrespective of compiler.

Ref: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l?view=msvc-170#remarks

Closes #xxxx

- Null terminate the end of the snprintf output buffer on Windows.

Old versions of the Windows CRT (which are often found on later versions
of Windows) do not terminate the snprintf output buffer if the output
reaches the max size.

This is a follow-up to 7e32f65 which made the same change but limited
it to mingw, however it is a CRT version issue irrespective of compiler.

Ref: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l?view=msvc-170#remarks

Closes #xxxx
@jay jay added the Windows Windows-specific label Jan 14, 2025
Copy link
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

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

Yikes. Nice catch!

@jay jay closed this in 8ab468c Jan 14, 2025
@jay jay deleted the snprintf_null branch January 14, 2025 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Windows Windows-specific
Development

Successfully merging this pull request may close these issues.

2 participants