]> git.ipfire.org Git - thirdparty/curl.git/commit
ftp: restore protocol state after http proxy CONNECT
authorTom Eccles <tom.eccles@codethink.co.uk>
Thu, 23 Jun 2022 09:09:25 +0000 (10:09 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 23 Jun 2022 14:07:20 +0000 (16:07 +0200)
commit71bbabb16755c3d611bb24909e77a0df688827aa
treecf380397609de088a2c0f82226e3b3521f611a5e
parentf3a778159421fd535805d79ee23a419e3bd58a00
ftp: restore protocol state after http proxy CONNECT

connect_init() (lib/http_proxy.c) swaps out the protocol state while
working on the proxy connection, this is then restored by
Curl_connect_done() after the connection completes.

ftp_do_more() extracted the protocol state pointer to a local variable
at the start of the function then calls Curl_proxy_connect(). If the proxy
connection completes, Curl_proxy_connect() will call Curl_connect_done()
(via Curl_proxyCONNECT()), which restores data->req.p to point to the ftp
protocol state instead of the http proxy protocol state, but the local
variable in ftp_do_more still pointed to the old value.

Ultimately this meant that the state worked on by ftp_do_more() was the
http proxy state not the ftp state initialised by ftp_connect(), but
subsequent calls to any ftp_ function would use the original state.

For my use-case, the visible consequence was that ftp->downloadsize was
never set and so downloaded data was never returned to the application.

This commit updates the ftp protocol state pointer in ftp_do_more() after
Curl_proxy_connect() returns, ensuring that the correct state pointer is
used.

Fixes #8737
Closes #9043
lib/ftp.c