From: Daniel Stenberg Date: Thu, 14 Dec 2023 15:34:25 +0000 (+0100) Subject: hostip: return error immediately when Curl_ip2addr() fails X-Git-Tag: curl-8_6_0~221 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=907dce2dc08ed2fec20b16b0f0ce5028e8042e01;p=thirdparty%2Fcurl.git hostip: return error immediately when Curl_ip2addr() fails Closes #12522 --- diff --git a/lib/hostip.c b/lib/hostip.c index e7c318af77..bcdc12270a 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -754,16 +754,22 @@ enum resolve_t Curl_resolv(struct Curl_easy *data, #ifndef USE_RESOLVE_ON_IPS /* First check if this is an IPv4 address string */ - if(Curl_inet_pton(AF_INET, hostname, &in) > 0) + if(Curl_inet_pton(AF_INET, hostname, &in) > 0) { /* This is a dotted IP address 123.123.123.123-style */ addr = Curl_ip2addr(AF_INET, &in, hostname, port); + if(!addr) + return CURLRESOLV_ERROR; + } #ifdef ENABLE_IPV6 - if(!addr) { + else { struct in6_addr in6; /* check if this is an IPv6 address string */ - if(Curl_inet_pton(AF_INET6, hostname, &in6) > 0) + if(Curl_inet_pton(AF_INET6, hostname, &in6) > 0) { /* This is an IPv6 address literal */ addr = Curl_ip2addr(AF_INET6, &in6, hostname, port); + if(!addr) + return CURLRESOLV_ERROR; + } } #endif /* ENABLE_IPV6 */