openldap: fix an LDAP crash

Reported-by: Ozan Cansel
Fixes #12593
Closes #12600
This commit is contained in:
Patrick Monnerat 2023-12-27 11:19:17 +01:00 committed by Daniel Stenberg
parent 68f96fc9bf
commit fa6e123929
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -887,10 +887,14 @@ static CURLcode oldap_do(struct Curl_easy *data, bool *done)
result = oldap_url_parse(data, &lud);
if(!result) {
Sockbuf *sb;
/* re-install the libcurl SSL handlers into the sockbuf. */
ldap_get_option(li->ld, LDAP_OPT_SOCKBUF, &sb);
ber_sockbuf_add_io(sb, &ldapsb_tls, LBER_SBIOD_LEVEL_TRANSPORT, data);
#ifdef USE_SSL
if(ssl_installed(conn)) {
Sockbuf *sb;
/* re-install the libcurl SSL handlers into the sockbuf. */
ldap_get_option(li->ld, LDAP_OPT_SOCKBUF, &sb);
ber_sockbuf_add_io(sb, &ldapsb_tls, LBER_SBIOD_LEVEL_TRANSPORT, data);
}
#endif
rc = ldap_search_ext(li->ld, lud->lud_dn, lud->lud_scope,
lud->lud_filter, lud->lud_attrs, 0,