Skip to content

openssl: fix handling of buffered data #17601

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

icing
Copy link
Contributor

@icing icing commented Jun 12, 2025

SSL_pending() only checks if the current TLS packet has more data. There might be more data in SSL's buffers.

SSL_has_pending() only checks if there is data in buffers, but does not check if there is a complete TLS packet that can be decoded.

If we only check the first, we will poll on socket events without having processed all data and may stall. If we only check the second, we would busy loop without SSL_read() ever giving something.

Add the flag connssl->input_pending that is set on incoming data in the BIO receive. Clear the flag when encountering a CURLE_AGAIN on the filters receive (via SSL_read()) or see an EOF.

refs #17596

icing added 2 commits June 12, 2025 09:50
`SSL_pending()` only checks if the *current* TLS packet has more
data. There might be more data in SSL's buffers.

`SSL_has_pending()` only checks if there is data in buffers, but
does *not* check if there is a complete TLS packet that can be
decoded.

If we only check the first, we will poll on socket events with
having processed all data and may stall. If we only check the
second, we would busy loop without SSL_read() ever giving something.

Add the flag `connssl->input_pending` that is set on incoming data
in the BIO receive. Clear the flag when encountering a CURLE_AGAIN
on the filters receive (via SSL_read()).

refs curl#17596
@icing icing requested review from vszakats and bagder June 12, 2025 08:42
@icing
Copy link
Contributor Author

icing commented Jun 12, 2025

@vszakats, when you have time it would be nice to merge this. Fixes Ci failures. Thanks!

@vszakats vszakats closed this in 1cdac95 Jun 12, 2025
@vszakats
Copy link
Member

Thanks @icing, merged!

denandz pushed a commit to denandz/curl that referenced this pull request Jun 21, 2025
`SSL_pending()` only checks if the *current* TLS packet has more data.
There might be more data in SSL's buffers.

`SSL_has_pending()` only checks if there is data in buffers, but does
*not* check if there is a complete TLS packet that can be decoded.

If we only check the first, we will poll on socket events without having
processed all data and may stall. If we only check the second, we would
busy loop without SSL_read() ever giving something.

Add the flag `connssl->input_pending` that is set on incoming data in
the BIO receive. Clear the flag when encountering a CURLE_AGAIN on
the filters receive (via SSL_read()) or see an EOF.

Ref: curl#17596
Closes curl#17601
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants