summaryrefslogtreecommitdiff
path: root/lib/ftp.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-06-24 01:13:04 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-06-24 09:10:44 +0200
commit03a87163a22e56a6c75510b61f8ac8d410208298 (patch)
treee93ba628d2d423ea63f9273354b19b74121ffa0b /lib/ftp.c
parentff1c37cbe37db360adc9b50128ae8abf225fda2d (diff)
downloadcurl-03a87163a22e56a6c75510b61f8ac8d410208298.tar.gz
Curl_inet_ntop: always check the return codebagder/Curl_inet_ntop
Reported-by: Siva Sivaraman Fixes #5412
Diffstat (limited to 'lib/ftp.c')
-rw-r--r--lib/ftp.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 175d2eea7..6fb4a3243 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -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 */
}