From: Patrick Monnerat Date: Wed, 27 Dec 2023 10:19:17 +0000 (+0100) Subject: openldap: fix an LDAP crash X-Git-Tag: curl-8_6_0~170 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fa6e123929de94064f1b1cb135f30b0a945ba399;p=thirdparty%2Fcurl.git openldap: fix an LDAP crash Reported-by: Ozan Cansel Fixes #12593 Closes #12600 --- diff --git a/lib/openldap.c b/lib/openldap.c index c9417fbe2a..fcc9f91f44 100644 --- a/lib/openldap.c +++ b/lib/openldap.c @@ -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,