]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
openldap: create ldap URLs correctly for IPv6 addresses
authorDaniel Stenberg <daniel@haxx.se>
Sat, 30 Mar 2024 10:14:54 +0000 (11:14 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 30 Mar 2024 21:50:26 +0000 (22:50 +0100)
Reported-by: Sergio Durigan Junior
Fixes #13228
Closes #13235

lib/openldap.c

index 47266f64e4473336636a2818fc17a44b34669486..85a37b8186041a31c26027455b7909a095cb843c 100644 (file)
@@ -548,9 +548,12 @@ static CURLcode oldap_connect(struct Curl_easy *data, bool *done)
       return result;
   }
 
-  hosturl = aprintf("ldap%s://%s:%d",
-                    conn->handler->flags & PROTOPT_SSL? "s": "",
-                    conn->host.name, conn->remote_port);
+  hosturl = aprintf("%s://%s%s%s:%d",
+                    conn->handler->scheme,
+                    conn->bits.ipv6_ip? "[": "",
+                    conn->host.name,
+                    conn->bits.ipv6_ip? "]": "",
+                    conn->remote_port);
   if(!hosturl)
     return CURLE_OUT_OF_MEMORY;