Skip to content

gopher: fix partial sends of CRLF - #22714

Closed
masancgui wants to merge 1 commit into
curl:masterfrom
masancgui:gopher-crlf-fix
Closed

masancgui wants to merge 1 commit into
curl:masterfrom
masancgui:gopher-crlf-fix

Conversation

@masancgui

@masancgui masancgui commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

I was reading the Gopher implementation and noticed that nwritten is never checked after sending the CRLF to the server. Reading here and there left me with the impression that this could lead to partial sends of the CRLF. The commit body better describes the changes.

@github-actions github-actions Bot added the tests label Aug 27, 2026
@testclutch

Copy link
Copy Markdown

Analysis of PR #22714 at 3d62f2a6:

Test 641 failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them).

Test 642 failed, which has NOT been flaky recently, so there could be a real issue in this PR. Note that this test has failed in 2 different CI jobs (the link just goes to one of them).

Generated by Testclutch

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

Fixes partial Gopher request terminator sends.

Changes:

  • Adds a reusable complete-buffer send loop.
  • Uses it for selectors and CRLF terminators.
  • Adds a Gopher header-dump test.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
lib/gopher.c Handles partial selector and CRLF sends.
tests/data/test5028 Tests client-visible Gopher headers.
tests/data/Makefile.am Registers the new test.

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

Comment thread tests/data/test5028
Extract the buffer-sending logic into
its own function so it can also be used
when sending CRLF. Previously, CRLF
could be partially sent to the server
without reporting an error or sending
the remaining bytes.

This commit preserves how the old code
handled errors while writing CRLF to
the client, which is why the extracted
function has a bool parameter.

This also includes a test case that
verifies that the header written to the
client contains exactly one CRLF. This
test case also detects the old buggy
behaviour of partial sends.
@masancgui

Copy link
Copy Markdown
Contributor Author

Hi, I applied the suggested fix (and added some context about it in the test file), clarified a comment in the Gopher implementation, and squashed the commits.

@bagder bagder closed this in 740ffee Aug 31, 2026
@bagder

bagder commented Aug 31, 2026

Copy link
Copy Markdown
Member

Thanks!

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.

4 participants