Skip to content

schannel, ignore error on recv beyond close notify#15381

Closed
icing wants to merge 2 commits into
curl:masterfrom
icing:schannel-close-recv-beyond
Closed

schannel, ignore error on recv beyond close notify#15381
icing wants to merge 2 commits into
curl:masterfrom
icing:schannel-close-recv-beyond

Conversation

@icing
Copy link
Copy Markdown
Contributor

@icing icing commented Oct 23, 2024

When receiving data, schannel does a recv from the lower filters, e.g. the socket, before it decrypts and analyses the buffered data it already has. When that buffer contains a close-notify, e.g. the end of the TLS stream, any error on the previous receive from the socket are not applicable to its return codes.

Example from #15345: a server sends a close notify and closes its connection. The encrypted data, including the close notify is received. Another receive on the sockets gets a CONNABORTED which curl reports as CURLE_RECV_ERROR. Schannel analyses its bufferi, sees the close notify and early returns to the caller. On this return, the error on the attempted receive does not apply.

When receiving data, schannel does a recv from the lower filters,
e.g. the socket, *before* it decrypts and analyses the buffered
data it already has. When that buffer contains a close-notify, e.g.
the end of the TLS stream, any error on the previous receive from
the socket are not applicable to its return codes.

Example from #153345: a server sends a close notify and closes its
connection. The encrypted data, including the close notify is received.
Another receive on the sockets gets a CONNABORTED which curl reports
as CURLE_RECV_ERROR. Schannel analyses its bufferi, sees the close
notify and early returns to the caller. On this return, the error
on the attempted receive does not apply.
@jay
Copy link
Copy Markdown
Member

jay commented Oct 24, 2024

It occurs to me though this works for shutdown it could potentially cause a problem during a transfer because the recv error state recv_unrecoverable_err is not returned for future calls, so it may be safer to handle this directly in shutdown if possible. In other words, we would want future recv calls to error. Let me know if you think #15391 would work

pps83 pushed a commit to pps83/curl that referenced this pull request Apr 26, 2025
When receiving data, schannel does a recv from the lower filters, e.g.
the socket, *before* it decrypts and analyses the buffered data it
already has. When that buffer contains a close-notify, e.g. the end of
the TLS stream, any error on the previous receive from the socket are
not applicable to its return codes.

Example from #153345: a server sends a close notify and closes its
connection. The encrypted data, including the close notify is received.
Another receive on the sockets gets a CONNABORTED which curl reports as
CURLE_RECV_ERROR. Schannel analyses its bufferi, sees the close notify
and early returns to the caller. On this return, the error on the
attempted receive does not apply.

Closes curl#15381
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

TLS Windows Windows-specific

Development

Successfully merging this pull request may close these issues.

3 participants