Skip to content

openssl: fix handling of buffered data#17601

Closed
icing wants to merge 2 commits intocurl:masterfrom
icing:ossl-pending-buffered
Closed

openssl: fix handling of buffered data#17601
icing wants to merge 2 commits intocurl:masterfrom
icing:ossl-pending-buffered

Conversation

@icing
Copy link
Copy Markdown
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 bagder and vszakats June 12, 2025 08:42
@icing
Copy link
Copy Markdown
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
Copy Markdown
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