Skip to content

telnet: return errors when poll or reading the input fails - #23548

Closed
Marti2203 wants to merge 1 commit into
curl:masterfrom
Marti2203:telnet-errors
Closed

Marti2203 wants to merge 1 commit into
curl:masterfrom
Marti2203:telnet-errors

Conversation

@Marti2203

Copy link
Copy Markdown
Contributor

On non-Windows systems, telnet_do() ends the transfer and returns CURLE_OK when:

  • poll() fails (it returns -1 only for errors other than EINTR),
  • read() of the CURLOPT_READDATA file fails, for example when it is a directory,
  • the read callback returns CURL_READFUNC_ABORT, which is documented to give CURLE_ABORTED_BY_CALLBACK.

So curl_easy_perform() reports success right away. This returns CURLE_RECV_ERROR, CURLE_READ_ERROR and CURLE_ABORTED_BY_CALLBACK instead. The Windows code returned CURLE_READ_ERROR for CURL_READFUNC_ABORT, and now also returns CURLE_ABORTED_BY_CALLBACK.

Test 1695 reuses lib513 (read callback returning CURL_READFUNC_ABORT) with a telnet URL; it fails without the change. I checked the other two cases by hand, with a directory as CURLOPT_READDATA and with poll() made to fail with ENOMEM through LD_PRELOAD.

The curl tool never returns CURL_READFUNC_ABORT and turns read errors into EOF, so it only sees the poll() change.

On non-Windows systems, telnet_do() ended the transfer and returned
CURLE_OK when poll() failed, when read() of the CURLOPT_READDATA file
failed and when the read callback returned CURL_READFUNC_ABORT. Return
CURLE_RECV_ERROR, CURLE_READ_ERROR and CURLE_ABORTED_BY_CALLBACK.

The Windows code returned CURLE_READ_ERROR for CURL_READFUNC_ABORT, make
it return CURLE_ABORTED_BY_CALLBACK as documented.

Add test 1695, using lib513 with a read callback that returns
CURL_READFUNC_ABORT.
@github-actions github-actions Bot added the tests label Oct 22, 2026
@Marti2203
Marti2203 marked this pull request as ready for review October 22, 2026 03:08
@bagder
bagder requested a balanced review from Copilot October 22, 2026 06:25

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

The localized error-handling changes match the intended behavior, include a focused regression test, and have no identified blocking issues.

No open issues 🎉

What changed in this PR

This PR makes TELNET transfers report input and polling failures instead of incorrectly returning success, and aligns callback-abort handling across platforms.

Changes:

  • Return appropriate errors for polling failures, input read failures, and callback aborts.
  • Add and register a regression test using lib513 to verify TELNET callback-abort behavior.
File Description
tests/​data/​test1695 Verify that a TELNET read callback abort returns error 42.
tests/​data/​Makefile.am Register test 1695.
lib/​telnet.c Propagate polling, input-read, and callback-abort errors.

Review effort: Balanced

@bagder

bagder commented Oct 22, 2026

Copy link
Copy Markdown
Member

Thanks!

@bagder bagder closed this in a873043 Oct 22, 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