mprintf: drop old sprintf fallback#20218
Closed
bagder wants to merge 1 commit into
Closed
Conversation
1. No modern systems lack snprintf() 2. If there actually exist any such systems, they get to manage without floating point output.
There was a problem hiding this comment.
Pull request overview
This PR removes the unsafe sprintf fallback for floating-point formatting in systems that lack snprintf() support. The rationale is that no modern systems lack snprintf(), and if any such legacy systems exist, they will simply not support floating-point output rather than using the unsafe sprintf function.
Key Changes
- Removed the old
sprintffallback that was used for float/double formatting whenHAVE_SNPRINTFis not defined - Replaced it with code that sets an empty string, effectively disabling float/double output on such systems
- Added a comment explaining that float and double outputs do not work without snprintf support
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
vszakats
added a commit
that referenced
this pull request
Feb 27, 2026
To support floats and doubles when using these old compilers. Before this patch, these tests most likely failed with them: ``` FAIL 557: 'curl_mprintf() testing' printf, unittest FAIL 566: 'HTTP GET with CURLINFO_CONTENT_LENGTH_DOWNLOAD and 0 bytes transfer' HTTP, HTTP GET FAIL 599: 'HTTP GET with progress callback and redirects changing content sizes' HTTP, HTTP POST, chunked Transfer-Encoding FAIL 1148: 'progress-bar' HTTP, progressbar ``` Also: - mention `_snprintf()` in the `_CRT_SECURE_NO_WARNINGS` comment. Follow-up to 7de3551 #20218 Closes #20761
outcast36
pushed a commit
to greearb/curl
that referenced
this pull request
Jun 3, 2026
To support floats and doubles when using these old compilers. Before this patch, these tests most likely failed with them: ``` FAIL 557: 'curl_mprintf() testing' printf, unittest FAIL 566: 'HTTP GET with CURLINFO_CONTENT_LENGTH_DOWNLOAD and 0 bytes transfer' HTTP, HTTP GET FAIL 599: 'HTTP GET with progress callback and redirects changing content sizes' HTTP, HTTP POST, chunked Transfer-Encoding FAIL 1148: 'progress-bar' HTTP, progressbar ``` Also: - mention `_snprintf()` in the `_CRT_SECURE_NO_WARNINGS` comment. Follow-up to 7de3551 curl#20218 Closes curl#20761
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.
No modern systems lack snprintf()
If there actually exist any such systems, they get to manage without floating point output.