]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
openldap: fix an LDAP crash
authorPatrick Monnerat <patrick@monnerat.net>
Wed, 27 Dec 2023 10:19:17 +0000 (11:19 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 27 Dec 2023 13:42:32 +0000 (14:42 +0100)
Reported-by: Ozan Cansel
Fixes #12593
Closes #12600

lib/openldap.c

index c9417fbe2a1c2b49ace18c18c8b1c0747c70159c..fcc9f91f44c3d9d9440192107eb8387a4f74ead0 100644 (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,