mprintf: use _snprintf() when compiled with VS2013 and older#20761
Closed
vszakats wants to merge 3 commits intocurl:masterfrom
Closed
mprintf: use _snprintf() when compiled with VS2013 and older#20761vszakats wants to merge 3 commits intocurl:masterfrom
_snprintf() when compiled with VS2013 and older#20761vszakats wants to merge 3 commits intocurl:masterfrom
Conversation
This was referenced Feb 27, 2026
vszakats
added a commit
that referenced
this pull request
Mar 2, 2026
…ows) Make the helper use `vsnprintf()` internally on all supported Windows toolchains (dropping `_snprintf()` and `snprintf()`), ensure to nul-terminate. Omit the return value to avoid complexity. Use the helper from `mprintf.c` / `out_double()`, from tests/server code and the tests/server-specific build of `curlx_inet_ntop()`, `curlx_strerror()` functions. In the single call (in tests) where the returned length was used previously, determine it with `strlen()`. Refs: https://github.com/libssh2/libssh2/blob/libssh2-1.11.1/src/misc.c#L57-L79 https://learn.microsoft.com/cpp/c-runtime-library/reference/snprintf-snprintf-snprintf-l-snwprintf-snwprintf-l https://learn.microsoft.com/cpp/c-runtime-library/reference/vsnprintf-vsnprintf-vsnprintf-l-vsnwprintf-vsnwprintf-l Assisted-by: Jay Satiro Follow-up to fa8bd1c #20761 Follow-up to 8ab468c #15997 Closes #20765
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
To support floats and doubles when using these old compilers.
Before this patch, these tests most likely failed with them:
Also:
_snprintf()in the_CRT_SECURE_NO_WARNINGScomment.Follow-up to 7de3551 #20218