]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/slapi/slapi_utils.c
allow to programmatically register new response code names
[openldap] / servers / slapd / slapi / slapi_utils.c
index 6c37e3b7f45be8d67baee5523e818ee0e97367a8..fafcde1b2faaa937fd09ef3dd1db55fcd4dfd085 100644 (file)
@@ -2153,7 +2153,6 @@ int slapi_attr_value_cmp( const Slapi_Attr *a, const struct berval *v1, const st
 int slapi_attr_value_find( const Slapi_Attr *a, struct berval *v )
 {
        int rc;
-       int ret;
 
        if ( a ->a_vals == NULL ) {
                return -1;
@@ -3216,21 +3215,27 @@ LDAP *slapi_ldap_init( char *ldaphost, int ldapport, int secure, int shared )
        int rc;
 
        size = sizeof("ldap:///");
-       if ( secure )
+       if ( secure ) {
                size++;
+       }
        size += strlen( ldaphost );
-       if ( ldapport != 0 )
+       if ( ldapport != 0 ) {
                size += 32;
+       }
 
        url = slapi_ch_malloc( size );
 
        if ( ldapport != 0 ) {
-               sprintf( url, "ldap%s://%s:%d/", ( secure ? "s" : "" ), ldaphost, ldapport );
+               rc = snprintf( url, size, "ldap%s://%s:%d/", ( secure ? "s" : "" ), ldaphost, ldapport );
        } else {
-               sprintf( url, "ldap%s://%s/", ( secure ? "s" : "" ), ldaphost );
+               rc = snprintf( url, size, "ldap%s://%s/", ( secure ? "s" : "" ), ldaphost );
        }
 
-       rc = ldap_initialize( &ld, url );
+       if ( rc > 0 && rc < size ) {
+               rc = ldap_initialize( &ld, url );
+       } else {
+               ld = NULL;
+       }
 
        slapi_ch_free_string( &url );