]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
http_proxy: Fix CONNECT chunked encoding race condition
authorJay Satiro <raysatiro@yahoo.com>
Mon, 11 Jan 2021 00:01:08 +0000 (19:01 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Mon, 11 Jan 2021 08:28:01 +0000 (03:28 -0500)
- During the end-of-headers response phase do not mark the tunnel
  complete unless the response body was completely parsed/ignored.

Prior to this change if the entirety of a CONNECT response with chunked
encoding was not received by the time the final header was parsed then
the connection would be marked done prematurely, before all the chunked
data could be read in and ignored (since this is what we do with any
CONNECT response body) and the connection could not be used.

Bug: https://curl.se/mail/lib-2021-01/0033.html
Reported-by: Fabian Keil
Closes https://github.com/curl/curl/pull/6432

lib/http_proxy.c

index 43bbe73d54ec8647ab30cc36f3fa858ce8bcbe77..2e0c8d35f3e6183157facf2ed460c664515b821f 100644 (file)
@@ -489,9 +489,12 @@ static CURLcode CONNECT(struct connectdata *conn,
           }
           else
             s->keepon = KEEPON_DONE;
-          if(!s->cl)
+
+          if(s->keepon == KEEPON_DONE && !s->cl)
             /* we did the full CONNECT treatment, go to COMPLETE */
             s->tunnel_state = TUNNEL_COMPLETE;
+
+          DEBUGASSERT(s->keepon == KEEPON_IGNORE || s->keepon == KEEPON_DONE);
           continue;
         }