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
Race Condition in Curl_proxyCONNECT (bug # 39) #1132
Comments
There is no known bugs numbered like that anymore so if you want something added to But then I also don't really see the big value of having this mentioned there. Isn't it instead much better to work on actually fixing the issue you have? Can you provide an example that repeats the problem and possible show us |
Sadly, it's a race condition. In some cases, libcurl will read the FTP welcome message as being the HTTP proxy response body and thus will never receive the FTP welcome. That means that it is almost impossible to reproduce predicatively with a real HTTP proxy. So, I've made a (partial) fake HTTP proxy server (curl39.txt). This (C++) program simply accept one connection and send back in a single write:
With this server and curl command lineline: As we can see, CURL never did see the welcome message from the FTP server (because it is the 32 bytes of opaque data). |
I've tested the fix of https://curl.haxx.se/mail/lib-2015-04/0169.html and it does resolve the problem. Sadly, it also break three tests (206, 1060 and 1061). All of those tests have HTTP proxy that return data in the proxy response. From the discussion on the mailing list, it appear that behaviour is broken for a HTTP proxy. What should be the next step? Should I open a pull request and move the discussion there or would it be better to discuss impact/alternatives in this issue first? |
Please do submit a PR. Regarding the test failures, it'd be great if you fixed them as well while at it. The spec text to lean on comes from RFC7231 section 4.3.6:
|
Here's my suggested patch for this problem: 0001-CONNECT-fix-race-condition.patch It now returns error on It actually also made me find and fix a bug that probably can happen with the old code if that would end up reading the response one byte at a time too (a rare scenario). This patch is a squashed version of three separate commits that I want to merge, but serves as easier to test. I've also updated a bunch of test cases that were broken (used wrong or no headers), and some that actually sent the unaligned data amounts - where |
I went ahead and merged. But please let me know if something doesn't work as it should! |
I've just tested it and the bug disappear with the correction. Thanks. |
Lovely, thanks for verifying. Now I feel more confident in the change! |
curl/libcurl version
libcurl v 7.51
operating system
Windows 7
Situation:
A FTPs transfer using a HTTP proxy sometime timeout with the following messages:
Note:
The bug # 39 is not in the list of known issue anymore. Commit b207ccb remove it.
It should be brought back and the error message should be updated to reference the new id.
Also, it is possible that others known issues where erased at the same time.
Previous discussions:
First mention: https://curl.haxx.se/mail/lib-2007-01/0045.html
Second discussion: https://curl.haxx.se/mail/lib-2015-04/0169.html
The text was updated successfully, but these errors were encountered: