Skip to content

sendf: clear reader stack when line-conversion setup fails - #23596

Closed
cmeister2 wants to merge 1 commit into
masterfrom
cm2/uaf
Closed

cmeister2 wants to merge 1 commit into
masterfrom
cm2/uaf

Conversation

@cmeister2

Copy link
Copy Markdown
Contributor

Clean up the installed readers in do_init_reader_stack() if adding the CRLF reader fails. Let Curl_creader_set() rely on that cleanup instead of freeing the client reader separately.

Add unit3307 to enable allocation failure from the reader length callback and verify cleanup without depending on allocation ordinals.

Clean up the installed readers in do_init_reader_stack() if adding the CRLF reader fails. Let Curl_creader_set() rely on that cleanup instead of freeing the client reader separately.

Add unit3307 to enable allocation failure from the reader length callback and verify cleanup without depending on allocation ordinals.

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.

🟢 Approval recommended

Cleanup ownership is consistent, and the regression test checks the failure result, empty stack, and exactly-once reader closure.

No open issues 🎉

What changed in this PR

This PR fixes reader-stack cleanup when CRLF line-conversion setup fails, preventing freed readers from remaining reachable.

Changes:

  • Reset the reader stack on line-conversion setup failure and remove redundant cleanup from Curl_creader_set().
  • Add a regression test that triggers allocation failure from the reader length callback and checks an empty stack and exactly-once closure.
  • Register the test with the unit-test build and test runner.
File Description
tests/​unit/​unit3307.c Tests reader cleanup after line-conversion allocation failure.
tests/​unit/​Makefile.inc Registers the new unit-test source.
tests/​data/​test3307 Defines the test and its memory-tracking requirements.
tests/​data/​Makefile.am Registers the test data file.
lib/​sendf.c Centralizes failure cleanup in reader-stack initialization.

Review effort: Balanced

@bagder
bagder requested a review from icing October 25, 2026 09:13
@bagder bagder closed this in 5e396f3 Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants