You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by bn...@apache.org on 2005/01/10 19:59:34 UTC

svn commit: r124821 - /apr/apr-util/trunk/ldap/apr_ldap_init.c

Author: bnicholes
Date: Mon Jan 10 10:59:32 2005
New Revision: 124821

URL: http://svn.apache.org/viewcvs?view=rev&rev=124821
Log:
-Since the apr_ldap_opt_tls_cert_t* structure is call be used as a linked list, make sure that it initialized to NULL before passing it into apr_ldap_set_option(). Otherwise the code will try to follow garbage links.
-Use the correct APR_LDAP_OPT_TLS_CERT #define when calling apr_ldap_set_option() to add a certificate.
-For the Novell LDAP SDK, always initialize the connection with ldapssl_init() function. Suggest that all SDKs do the same.
Modified:
   apr/apr-util/trunk/ldap/apr_ldap_init.c

Modified: apr/apr-util/trunk/ldap/apr_ldap_init.c
Url: http://svn.apache.org/viewcvs/apr/apr-util/trunk/ldap/apr_ldap_init.c?view=diff&rev=124821&p1=apr/apr-util/trunk/ldap/apr_ldap_init.c&r1=124820&p2=apr/apr-util/trunk/ldap/apr_ldap_init.c&r2=124821
==============================================================================
--- apr/apr-util/trunk/ldap/apr_ldap_init.c	(original)
+++ apr/apr-util/trunk/ldap/apr_ldap_init.c	Mon Jan 10 10:59:32 2005
@@ -65,10 +65,10 @@
 
     /* if a certificate was specified, set it */
     if (cert_auth_file) {
-        apr_ldap_opt_tls_cert_t *cert = (apr_ldap_opt_tls_cert_t *)apr_palloc(pool, sizeof(apr_ldap_opt_tls_cert_t));
+        apr_ldap_opt_tls_cert_t *cert = (apr_ldap_opt_tls_cert_t *)apr_pcalloc(pool, sizeof(apr_ldap_opt_tls_cert_t));
         cert->type = cert_file_type;
         cert->path = cert_auth_file;
-        return apr_ldap_set_option(pool, NULL, APR_LDAP_OPT_TLS, (void *)cert, result_err);
+        return apr_ldap_set_option(pool, NULL, APR_LDAP_OPT_TLS_CERT, (void *)cert, result_err);
     }
 
 #else  /* not compiled with SSL Support */
@@ -144,7 +144,16 @@
     apr_ldap_err_t *result = (apr_ldap_err_t *)apr_pcalloc(pool, sizeof(apr_ldap_err_t));
     *result_err = result;
 
+#if APR_HAS_NOVELL_LDAPSDK
+    if (secure == APR_LDAP_SSL) {
+        *ldap = ldapssl_init(hostname, portno, 1);
+    }
+    else {
+        *ldap = ldapssl_init(hostname, portno, 0);
+    }
+#else
     *ldap = ldap_init((char *)hostname, portno);
+#endif
     if (*ldap != NULL) {
         return apr_ldap_set_option(pool, *ldap, APR_LDAP_OPT_TLS, &secure, result_err);
     }