diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-06-24 01:13:04 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-06-24 16:04:54 +0200 |
commit | d2baa502fc7ea3f003db2d13b110f3f1da8d8073 (patch) | |
tree | 77ae009ffc8ef051e85ba377d44f0e94ed1cbdae /lib/ftp.c | |
parent | 550bcdd442dcd6d32e9ef018dbcb72b06365a03c (diff) | |
download | curl-d2baa502fc7ea3f003db2d13b110f3f1da8d8073.tar.gz |
Curl_inet_ntop: always check the return code
Reported-by: Siva Sivaraman
Fixes #5412
Closes #5597
Diffstat (limited to 'lib/ftp.c')
-rw-r--r-- | lib/ftp.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -1043,6 +1043,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, } /* data->set.ftpport */ if(!host) { + const char *r; /* not an interface and not a host name, get default by extracting the IP from the control connection */ sslen = sizeof(ss); @@ -1055,13 +1056,15 @@ static CURLcode ftp_state_use_port(struct connectdata *conn, switch(sa->sa_family) { #ifdef ENABLE_IPV6 case AF_INET6: - Curl_inet_ntop(sa->sa_family, &sa6->sin6_addr, hbuf, sizeof(hbuf)); + r = Curl_inet_ntop(sa->sa_family, &sa6->sin6_addr, hbuf, sizeof(hbuf)); break; #endif default: - Curl_inet_ntop(sa->sa_family, &sa4->sin_addr, hbuf, sizeof(hbuf)); + r = Curl_inet_ntop(sa->sa_family, &sa4->sin_addr, hbuf, sizeof(hbuf)); break; } + if(!r) + return CURLE_FTP_PORT_FAILED; host = hbuf; /* use this host name */ possibly_non_local = FALSE; /* we know it is local now */ } |