1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

ldap_client: Make ldap_parse_basic_url() IPv6-address aware

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Jul  2 12:01:06 UTC 2020 on sn-devel-184
This commit is contained in:
Volker Lendecke 2020-07-01 16:10:17 +02:00
parent 61bc99362a
commit 7082902d56

View File

@ -376,6 +376,33 @@ static int ldap_parse_basic_url(
return EPROTONOSUPPORT;
}
if (url[0] == '[') {
/*
* IPv6 with [aa:bb:cc..]:port
*/
const char *end = NULL;
url +=1;
end = strchr(url, ']');
if (end == NULL) {
return EINVAL;
}
ret = sscanf(end+1, ":%d", &port);
if (ret < 0) {
return EINVAL;
}
*pdest = talloc_strndup(mem_ctx, url, end-url);
if (*pdest == NULL) {
return ENOMEM;
}
*pproto = proto;
*pport = port;
return 0;
}
ret = sscanf(url, "%m[^:/]:%d", &host, &port);
if (ret < 1) {
return EINVAL;