Repository navigation
Fix smtp starttls - #13048
Closed
Flakebi wants to merge 1 commit into
Closed
Fix smtp starttls#13048Flakebi wants to merge 1 commit into
Flakebi wants to merge 1 commit into
Conversation
In cases where the connection was fast, curl sometimes failed to open a connection. This fixes a regression of c2d9736. The regression triggered in these steps: 1. Create an smtp connection 2. Use STARTTLS 3. Receive the response 4. We are inside the loop in `smtp_statemachine`, calling `smtp_state_starttls_resp` 5. In the good flow, we exit the loop, re-enter `smtp_statemachine` and run `smtp_perform_upgrade_tls` at the start of the function. In the bad flow, we stay in the while loop, calling `Curl_pp_readresp`, which reads part of the TLS handshake and things go wrong. The reason is that `Curl_pp_moredata` changed behavior and always returns `true`, so we stay in the loop in `smtp_statemachine`. With a slow connection `Curl_pp_readresp` cannot read new data and returns `CURL_AGAIN`, so we leave the loop and re-enter `smtp_statemachine`. With a fast connection, `Curl_pp_readresp` reads new data from the tcp connection, which is part of the TLS handshake. The fix is in `Curl_pp_moredata`, which needs to take the final line into account and return `false` if only the final line is stored.
bagder
approved these changes
Mar 5, 2024
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In cases where the connection was fast, curl sometimes failed to open a connection.
This fixes a regression of c2d9736.
The regression triggered in these steps:
Create an smtp connection
Use STARTTLS
Receive the response
We are inside the loop in
smtp_statemachine, callingsmtp_state_starttls_respIn the good flow, we exit the loop, re-enter
smtp_statemachineand runsmtp_perform_upgrade_tlsat the start of the function.In the bad flow, we stay in the while loop, calling
Curl_pp_readresp, which reads part of the TLS handshake and things go wrong.The reason is that
Curl_pp_moredatachanged behavior and always returnstrue, so we stay in the loop insmtp_statemachine. With a slow connectionCurl_pp_readrespcannot read new data and returnsCURL_AGAIN, so we leave the loop and re-entersmtp_statemachine.With a fast connection,
Curl_pp_readrespreads new data from the tcp connection, which is part of the TLS handshake.The fix is in
Curl_pp_moredata, which needs to take the final line into account and returnfalseif only the final line is stored.A test would be nice, but I’m not accustomed to the testing system, so I there’s no test in this change.