1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
From: Daniel Stenberg <daniel@haxx.se>
Date: Sat, 30 Mar 2024 11:14:54 +0100
Subject: openldap: create ldap URLs correctly for IPv6 addresses
Reported-by: Sergio Durigan Junior
Fixes #13228
Closes #13235
More context:
When the user specified an IPv6 address to be used as an LDAP server,
curl will fail to properly enclose it in square brackets, which causes
the connection to fail because the host address cannot be
distinguished from the port:
$ curl -v ldap://[fd42:be5:e632:a6b3:216:3eff:feb1:5bc4]:389
...
* LDAP local: Cannot connect to ldap://fd42:be5:e632:a6b3:216:3eff:feb1:5bc4:389, Bad parameter to an ldap routine
...
Fix this by always enclosing the IPv6 address in square brackets.
Origin: upstream, https://github.com/curl/curl/commit/56935a7dada6975d5a46aa494de0af195e4e8659
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1053643
---
lib/openldap.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
Index: curl/lib/openldap.c
===================================================================
--- curl.orig/lib/openldap.c
+++ curl/lib/openldap.c
@@ -547,9 +547,12 @@ static CURLcode oldap_connect(struct Cur
(void)done;
- 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;
|