Skip to content

mprintf: drop old sprintf fallback#20218

Closed
bagder wants to merge 1 commit into
masterfrom
bagder/mprintf-no-snprintf
Closed

mprintf: drop old sprintf fallback#20218
bagder wants to merge 1 commit into
masterfrom
bagder/mprintf-no-snprintf

Conversation

@bagder

@bagder bagder commented Jan 8, 2026

Copy link
Copy Markdown
Member
  1. No modern systems lack snprintf()

  2. If there actually exist any such systems, they get to manage without floating point output.

1. No modern systems lack snprintf()

2. If there actually exist any such systems, they get to manage without
   floating point output.
@bagder bagder marked this pull request as ready for review January 8, 2026 08:14
@bagder bagder requested a review from Copilot January 8, 2026 08:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 sprintf fallback that was used for float/double formatting when HAVE_SNPRINTF is 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.

@bagder bagder closed this in 7de3551 Jan 8, 2026
@bagder bagder deleted the bagder/mprintf-no-snprintf branch January 8, 2026 08:31
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants