Skip to content

make mprintf() and mfprintf() return -1 on error - #23112

Closed
bagder wants to merge 1 commit into
masterfrom
bagder/fprintf-fail
Closed

bagder wants to merge 1 commit into
masterfrom
bagder/fprintf-fail

Conversation

@bagder

@bagder bagder commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Previously they returned the number of characters it output at the time of the error, but that is not only contrary to what POSIX does, it also makes it next to impossible for a caller to know when for example the output failed because out of disk space or similar.

@testclutch

This comment was marked as resolved.

Previously they returned the number of characters it output at the time
of the error, but that is not only contrary to what POSIX does, it also
makes it next to impossible for a caller to know when for example the
output failed because out of disk space or similar.

Verified by test 2380
Closes #23112
@bagder
bagder force-pushed the bagder/fprintf-fail branch from 656df08 to bf582f1 Compare September 26, 2026 08:40
@bagder
bagder marked this pull request as ready for review September 26, 2026 08:40
@bagder
bagder requested a balanced review from Copilot September 26, 2026 08:40

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.

Copilot review overview

🟡 Changes recommended

The regression test currently succeeds even when curl_mfprintf never returns -1.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates curl’s printf wrappers to report output failures consistently with POSIX behavior.

Changes:

  • Return -1 when file output fails.
  • Add an RLIMIT_FSIZE regression test.
  • Document the new return behavior.
File Description
lib/​mprintf.c Tracks and reports stream write failures.
docs/​libcurl/​curl_mprintf.md Documents error return semantics.
tests/​libtest/​lib2380.c Exercises output failure handling.
tests/​libtest/​Makefile.inc Registers the new libtest.
tests/​data/​test2380 Defines the test case.
tests/​data/​Makefile.am Registers the test data.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/libtest/lib2380.c Resolved
@bagder bagder closed this in 941cda6 Sep 26, 2026
@bagder
bagder deleted the bagder/fprintf-fail branch September 26, 2026 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants