ftp: retry getpeername for FTP with TCP_FASTOPEN

In the case of TFO, the remote host name is not resolved at the
connetion time.

For FTP that has lead to missing hostname for the secondary connection.
Therefore the name resolution is done at the time, when FTP requires it.

Fixes #6252
Closes #6265
Closes #6282
This commit is contained in:
Klaus Crusius 2020-11-28 18:17:11 +01:00 committed by Daniel Stenberg
parent 7a6fdd503d
commit 2c0d721215
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 71 additions and 46 deletions

View file

@ -1940,6 +1940,17 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
#endif
{
/* normal, direct, ftp connection */
DEBUGASSERT(ftpc->newhost);
/* postponed address resolution in case of tcp fastopen */
if(conn->bits.tcp_fastopen && !conn->bits.reuse && !ftpc->newhost[0]) {
Curl_conninfo_remote(conn, conn->sock[FIRSTSOCKET]);
Curl_safefree(ftpc->newhost);
ftpc->newhost = strdup(control_address(conn));
if(!ftpc->newhost)
return CURLE_OUT_OF_MEMORY;
}
rc = Curl_resolv(conn, ftpc->newhost, ftpc->newport, FALSE, &addr);
if(rc == CURLRESOLV_PENDING)
/* BLOCKING */