Repository navigation
Conversation
Curl_req_hard_reset() keeps the client reader stack when a rewind is pending and only clears the flag afterwards, so when a redirect with a request body fails before the follow-up request is set up, the readers of the previous body stay installed into the next transfer on the same easy handle. An upload over a protocol that uses the generic reader (ftp, sftp, scp, file, tftp) then reads through the stale stack, and if the postfields were replaced in between that memory is gone. Clear a pending rewind and reset the readers in Curl_pretransfer(), a new transfer never wants a rewind of the previous body.
bagder
approved these changes
Oct 20, 2026
dkarpov1970
pushed a commit
to dkarpov1970/curl
that referenced
this pull request
Nov 18, 2026
Curl_req_hard_reset() keeps the client reader stack when a rewind is pending and only clears the flag afterwards, so when a redirect with a request body fails before the follow-up request is set up, the readers of the previous body stay installed into the next transfer on the same easy handle. An upload over a protocol that uses the generic reader (ftp, sftp, scp, file, tftp) then reads through the stale stack, and if the postfields were replaced in between that memory is gone. Clear a pending rewind and reset the readers in Curl_pretransfer(), a new transfer never wants a rewind of the previous body. Closes curl#23505 (cherry picked from commit acf8a65)
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.
Curl_req_hard_reset() keeps the client reader stack when a rewind is pending and clears the flag only afterwards, so when a redirect with a request body fails before the follow-up request gets set up (a 307 with a Location curl cannot parse, or a 307 with a header line without a colon, with FOLLOWLOCATION on), the readers of the previous body stay installed into the next transfer on the same easy handle. The next upload over a protocol that uses the generic reader (ftp, sftp, scp, file, tftp) reads through that stale stack instead of the new READDATA, and if the postfields were replaced in between the memory it reads is gone. Reproduced on 8.23.0 with one easy handle doing a COPYPOSTFIELDS POST that gets such a 307, then a file:// or ftp:// upload without curl_easy_reset(); with this change the second transfer reads its own data again and the full suite is unchanged (8.16.0 and later have the ordering).