]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
hostip: return error immediately when Curl_ip2addr() fails
authorDaniel Stenberg <daniel@haxx.se>
Thu, 14 Dec 2023 15:34:25 +0000 (16:34 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 14 Dec 2023 21:57:28 +0000 (22:57 +0100)
Closes #12522

lib/hostip.c

index e7c318af77f50eb3583d906960850dfb6258603e..bcdc12270a6777409bd82bc78e75c994690913b7 100644 (file)
@@ -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 */