]> git.sur5r.net Git - openldap/commitdiff
leftover ber_bvdup eliminated; rewritten ber_bvdup in terms of ber_dupbv; eliminated...
authorPierangelo Masarati <ando@openldap.org>
Sat, 5 Jan 2002 17:49:59 +0000 (17:49 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 5 Jan 2002 17:49:59 +0000 (17:49 +0000)
12 files changed:
include/lber.h
libraries/liblber/memory.c
servers/slapd/back-bdb/search.c
servers/slapd/back-ldbm/search.c
servers/slapd/back-meta/back-meta.h
servers/slapd/back-meta/bind.c
servers/slapd/back-meta/candidates.c
servers/slapd/back-meta/conn.c
servers/slapd/back-meta/init.c
servers/slapd/back-monitor/init.c
servers/slapd/schema_init.c
servers/slapd/slap.h

index 2a7977c24f786b38cddacb18faf0a5c03fc1ca47..c3bc498509d95f2cf27d86656f6e4f8df6589f5a 100644 (file)
@@ -558,7 +558,9 @@ LBER_F( struct berval * )
 ber_dupbv LDAP_P((
        struct berval *dst, LDAP_CONST struct berval *src ));
 
-#define        ber_bvdup(bv)   ber_dupbv(NULL, bv)
+LBER_F( struct berval * )
+ber_bvdup LDAP_P((
+       LDAP_CONST struct berval *src ));
 
 LBER_F( struct berval * )
 ber_str2bv LDAP_P((
index b357ca85340c8a05830dc8ff54a5a0422bc667a5..3c660f6a2b81d46f950cf0ea0a90b506db688bbf 100644 (file)
@@ -487,6 +487,15 @@ ber_dupbv(
        return new;
 }
 
+
+struct berval *
+ber_bvdup(
+       LDAP_CONST struct berval *src )
+{
+       return ber_dupbv( NULL, src );
+}
+
+
 struct berval *
 ber_str2bv(
        LDAP_CONST char *s, ber_len_t len, int dup, struct berval *bv)
index d513b999ff149afc56dd370d6efcdecd9044a9eb..3106ceae3aa7872bff0d1427ac378ab5278dc5fa 100644 (file)
@@ -92,12 +92,13 @@ bdb_search(
        }
 
        if ( e == NULL ) {
-               struct berval *matched_dn = NULL;
+               struct berval matched_dn = { 0, NULL };
                BVarray refs = NULL;
 
                if ( matched != NULL ) {
                        BVarray erefs;
-                       matched_dn = ber_bvdup( &matched->e_name );
+
+                       ber_dupbv( &matched_dn, &matched->e_name );
 
                        erefs = is_entry_referral( matched )
                                ? get_entry_referrals( be, conn, op, matched )
@@ -107,7 +108,7 @@ bdb_search(
                        matched = NULL;
 
                        if( erefs ) {
-                               refs = referral_rewrite( erefs, matched_dn,
+                               refs = referral_rewrite( erefs, &matched_dn,
                                        base, scope );
                                bvarray_free( erefs );
                        }
@@ -118,16 +119,18 @@ bdb_search(
                }
 
                send_ldap_result( conn, op,     rc=LDAP_REFERRAL ,
-                       matched_dn ? matched_dn->bv_val : NULL, text, refs, NULL );
+                       matched_dn.bv_val, text, refs, NULL );
 
                if ( refs ) bvarray_free( refs );
-               if ( matched_dn ) ber_bvfree( matched_dn );
+               if ( matched_dn.bv_val ) ber_memfree( matched_dn.bv_val );
                return rc;
        }
 
        if (!manageDSAit && e != &slap_entry_root && is_entry_referral( e ) ) {
                /* entry is a referral, don't allow add */
-               struct berval *matched_dn = ber_bvdup( &e->e_name );
+               struct berval matched_dn;
+               
+               ber_dupbv( &matched_dn, &e->e_name );
                BVarray erefs = get_entry_referrals( be, conn, op, e );
                BVarray refs = NULL;
 
@@ -135,7 +138,7 @@ bdb_search(
                e = NULL;
 
                if( erefs ) {
-                       refs = referral_rewrite( erefs, matched_dn,
+                       refs = referral_rewrite( erefs, &matched_dn,
                                base, scope );
                        bvarray_free( erefs );
                }
@@ -144,12 +147,12 @@ bdb_search(
                        0, 0, 0 );
 
                send_ldap_result( conn, op, LDAP_REFERRAL,
-                       matched_dn->bv_val,
+                       matched_dn.bv_val,
                        refs ? NULL : "bad referral object",
                        refs, NULL );
 
                bvarray_free( refs );
-               ber_bvfree( matched_dn );
+               ber_memfree( matched_dn.bv_val );
                return 1;
        }
 
index 67452f53d01f30d598b0abbf2c1f14dc4165bdcb..36f8bc0a7a84bcfa75d8fbf7378933db082c5adf 100644 (file)
@@ -91,12 +91,12 @@ ldbm_back_search(
        }
 
        if ( e == NULL ) {
-               struct berval *matched_dn = NULL;
+               struct berval matched_dn = { 0, NULL };
                BVarray refs = NULL;
 
                if ( matched != NULL ) {
                        BVarray erefs;
-                       matched_dn = ber_bvdup( &matched->e_name );
+                       ber_dupbv( &matched_dn, &matched->e_name );
 
                        erefs = is_entry_referral( matched )
                                ? get_entry_referrals( be, conn, op, matched )
@@ -105,7 +105,7 @@ ldbm_back_search(
                        cache_return_entry_r( &li->li_cache, matched );
 
                        if( erefs ) {
-                               refs = referral_rewrite( erefs, matched_dn,
+                               refs = referral_rewrite( erefs, &matched_dn,
                                        base, scope );
 
                                bvarray_free( erefs );
@@ -116,18 +116,19 @@ ldbm_back_search(
                                NULL, base, scope );
                }
 
-               send_ldap_result( conn, op, err,
-                       matched_dn ? matched_dn->bv_val : NULL, 
+               send_ldap_result( conn, op, err, matched_dn.bv_val, 
                        text, refs, NULL );
 
                bvarray_free( refs );
-               ber_bvfree( matched_dn );
+               ber_memfree( matched_dn.bv_val );
                return 1;
        }
 
        if (!manageDSAit && is_entry_referral( e ) ) {
                /* entry is a referral, don't allow add */
-               struct berval *matched_dn = ber_bvdup( &e->e_name );
+               struct berval matched_dn;
+
+               ber_dupbv( &matched_dn, &e->e_name );
                BVarray erefs = get_entry_referrals( be, conn, op, e );
                BVarray refs = NULL;
 
@@ -144,7 +145,7 @@ ldbm_back_search(
 #endif
 
                if( erefs ) {
-                       refs = referral_rewrite( erefs, matched_dn,
+                       refs = referral_rewrite( erefs, &matched_dn,
                                base, scope );
 
                        bvarray_free( erefs );
@@ -152,16 +153,16 @@ ldbm_back_search(
 
                if( refs ) {
                        send_ldap_result( conn, op, LDAP_REFERRAL,
-                               matched_dn->bv_val, NULL, refs, NULL );
+                               matched_dn.bv_val, NULL, refs, NULL );
                        bvarray_free( refs );
 
                } else {
                        send_ldap_result( conn, op, LDAP_OTHER,
-                               matched_dn->bv_val,
+                               matched_dn.bv_val,
                        "bad referral object", NULL, NULL );
                }
 
-               ber_bvfree( matched_dn );
+               ber_memfree( matched_dn.bv_val );
                return 1;
        }
 
index dcbe64632c22399b0244e0d125c6f0df0d079251..2862d1c2f84900d8fa00de4d6d529e0064938185 100644 (file)
@@ -89,7 +89,7 @@ struct metasingleconn {
 #define        META_CANDIDATE          1
        
        LDAP                    *ld;
-       struct berval           *bound_dn;
+       struct berval           bound_dn;
        int                     bound;
 #define META_UNBOUND           0
 #define META_BOUND             1
index 4d54f63580fad102601ba70e4856b481510e638a..e988bd0a79e67905de6f25f91e5d024a8bab556c 100644 (file)
@@ -254,7 +254,7 @@ meta_back_do_single_bind(
        if ( rc != LDAP_SUCCESS ) {
                rc = ldap_back_map_result( rc );
        } else {
-               lc->conns[ candidate ]->bound_dn = ber_bvdup( dn );
+               ber_dupbv( &lc->conns[ candidate ]->bound_dn, dn );
                lc->conns[ candidate ]->bound = META_BOUND;
                lc->bound_target = candidate;
 
@@ -311,7 +311,7 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
                 * (note: if the target was already bound, the anonymous
                 * bind clears the previous bind).
                 */
-               rc = ldap_bind_s( lsc[ 0 ]->ld, lsc[ 0 ]->bound_dn->bv_val,
+               rc = ldap_bind_s( lsc[ 0 ]->ld, lsc[ 0 ]->bound_dn.bv_val,
                                NULL, LDAP_AUTH_SIMPLE );
                if ( rc != LDAP_SUCCESS ) {
                        
@@ -320,14 +320,14 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
                                        "meta_back_dobind: (anonymous)"
                                        " bind as \"%s\" failed"
                                        " with error \"%s\"\n",
-                                       lsc[ 0 ]->bound_dn->bv_val,
+                                       lsc[ 0 ]->bound_dn.bv_val,
                                        ldap_err2string( rc ) ));
 #else /* !NEW_LOGGING */
                        Debug( LDAP_DEBUG_ANY,
                                        "==>meta_back_dobind: (anonymous)"
                                        " bind as \"%s\" failed"
                                        " with error \"%s\"\n%s",
-                                       lsc[ 0 ]->bound_dn->bv_val,
+                                       lsc[ 0 ]->bound_dn.bv_val,
                                        ldap_err2string( rc ), "" );
 #endif /* !NEW_LOGGING */
 
index a87dbfbdc4378a443680caff29d04226da9733e2..4fb312dc089efa2c1ee1e532e4398fdd213113ee 100644 (file)
@@ -242,9 +242,10 @@ meta_clear_one_candidate(
                lsc->ld = NULL;
        }
 
-       if ( lsc->bound_dn != NULL ) {
-               ber_bvfree( lsc->bound_dn );
-               lsc->bound_dn = NULL;
+       if ( lsc->bound_dn.bv_val != NULL ) {
+               ber_memfree( lsc->bound_dn.bv_val );
+               lsc->bound_dn.bv_val = NULL;
+               lsc->bound_dn.bv_len = 0;
        }
 
        return 0;
index b0fbf8e7d863e6ab5274a7fc46cbd171915d46a2..c665a27165a94053aa30809ee2582edff99bcdc8 100644 (file)
@@ -276,26 +276,26 @@ init_one_conn(
         * If the connection dn is not null, an attempt to rewrite it is made
         */
        if ( conn->c_cdn != 0 ) {
-               char *mdn = NULL;
                
                /*
                 * Rewrite the bind dn if needed
                 */
-               lsc->bound_dn = NULL;
+               lsc->bound_dn.bv_val = NULL;
                switch ( rewrite_session( lt->rwinfo, "bindDn",
-                                       conn->c_cdn, conn, &mdn ) ) {
+                                       conn->c_cdn, conn, 
+                                       &lsc->bound_dn.bv_val ) ) {
                case REWRITE_REGEXEC_OK:
-                       if ( mdn == NULL ) {
-                               lsc->bound_dn = ber_bvstrdup( conn->c_cdn );
+                       if ( lsc->bound_dn.bv_val == NULL ) {
+                               ber_str2bv( conn->c_cdn, 0, 1, &lsc->bound_dn );
                        }
 #ifdef NEW_LOGGING
                        LDAP_LOG(( "backend", LDAP_LEVEL_DETAIL1,
                                        "[rw] bindDn: \"%s\" -> \"%s\"\n",
-                                       conn->c_cdn, lsc->bound_dn->bv_val ));
+                                       conn->c_cdn, lsc->bound_dn.bv_val ));
 #else /* !NEW_LOGGING */
                        Debug( LDAP_DEBUG_ARGS,
                                        "rw> bindDn: \"%s\" -> \"%s\"\n",
-                                       conn->c_cdn, lsc->bound_dn->bv_val, 0 );
+                                       conn->c_cdn, lsc->bound_dn.bv_val, 0 );
 #endif /* !NEW_LOGGING */
                        break;
                        
@@ -314,14 +314,10 @@ init_one_conn(
                        return LDAP_OPERATIONS_ERROR;
                }
 
-               if ( mdn ) {
-                       lsc->bound_dn = ber_bvstr( mdn );
-               } else {
-                       lsc->bound_dn = ber_bvstrdup( "" );
-               }
+               assert( lsc->bound_dn.bv_val );
 
        } else {
-               lsc->bound_dn = ber_bvstrdup( "" );
+               ber_str2bv( "", 0, 1, &lsc->bound_dn );
        }
 
        lsc->bound = META_UNBOUND;
index 1b63a0b746b7a63806801df0e0ea8fb1727fdf9b..a67429367e83af02504722b33cd30ce6dc212e4f 100644 (file)
@@ -164,8 +164,8 @@ conn_free(
                if ( lsc[ 0 ]->ld != NULL ) {
                        ldap_unbind( lsc[ 0 ]->ld );
                }
-               if ( lsc[ 0 ]->bound_dn ) {
-                       ber_bvfree( lsc[ 0 ]->bound_dn );
+               if ( lsc[ 0 ]->bound_dn.bv_val ) {
+                       ber_memfree( lsc[ 0 ]->bound_dn.bv_val );
                }
                free( lsc[ 0 ] );
        }
index 70bd84804c5008e0932f2f6f93256452a1b4e4b6..56b3cb38b399825f8f6c7b739b1910dc10283a95 100644 (file)
@@ -256,7 +256,7 @@ monitor_back_db_init(
                return -1;
        }
 
-       ber_bvecadd( &be->be_suffix, ber_bvdup( &dn ) );
+       ber_bvecadd( &be->be_suffix, ber_dupbv( NULL, &dn ) );
        ber_bvecadd( &be->be_nsuffix, ndn );
 
        mi = ( struct monitorinfo * )ch_calloc( sizeof( struct monitorinfo ), 1 );
index b34bcb476e45cb3bff52f11209e5b94e89b5c998..4b49e541a532fee7f9ed51d620c612d35e1a7130 100644 (file)
@@ -222,38 +222,38 @@ nameUIDValidate(
        struct berval *in )
 {
        int rc;
-       struct berval *dn;
+       struct berval dn;
 
        if( in->bv_len == 0 ) return LDAP_SUCCESS;
 
-       dn = ber_bvdup( in );
-       if( !dn ) return LDAP_OTHER;
+       ber_dupbv( &dn, in );
+       if( !dn.bv_val ) return LDAP_OTHER;
 
-       if( dn->bv_val[dn->bv_len-1] == 'B'
-               && dn->bv_val[dn->bv_len-2] == '\'' )
+       if( dn.bv_val[dn.bv_len-1] == 'B'
+               && dn.bv_val[dn.bv_len-2] == '\'' )
        {
                /* assume presence of optional UID */
                ber_len_t i;
 
-               for(i=dn->bv_len-3; i>1; i--) {
-                       if( dn->bv_val[i] != '0' &&     dn->bv_val[i] != '1' ) {
+               for(i=dn.bv_len-3; i>1; i--) {
+                       if( dn.bv_val[i] != '0' &&      dn.bv_val[i] != '1' ) {
                                break;
                        }
                }
-               if( dn->bv_val[i] != '\'' ||
-                   dn->bv_val[i-1] != '#' ) {
-                       ber_bvfree( dn );
+               if( dn.bv_val[i] != '\'' ||
+                   dn.bv_val[i-1] != '#' ) {
+                       ber_memfree( dn.bv_val );
                        return LDAP_INVALID_SYNTAX;
                }
 
                /* trim the UID to allow use of dnValidate */
-               dn->bv_val[i-1] = '\0';
-               dn->bv_len = i-1;
+               dn.bv_val[i-1] = '\0';
+               dn.bv_len = i-1;
        }
 
-       rc = dnValidate( NULL, dn );
+       rc = dnValidate( NULL, &dn );
 
-       ber_bvfree( dn );
+       ber_memfree( &dn );
        return rc;
 }
 
@@ -3575,7 +3575,7 @@ serial_and_issuer_parse(
 
        bv.bv_len = end-begin+1;
        bv.bv_val = begin;
-       *serial = ber_bvdup(&bv);
+       *serial = ber_dupbv(NULL, &bv);
 
        /* now extract the issuer, remember p was at the dollar sign */
        begin = p+1;
index 6226741198e8a382a7e3b0cff26cc9ea0c6cf35d..13c932185dc74ca39dc0b892d4b7bf6ca71d22ff 100644 (file)
@@ -1408,7 +1408,6 @@ typedef struct sasl_regexp {
 #define FLAG_GETDN_AUTHCID 2
 #define FLAG_GETDN_AUTHZID 4
 
-
 LDAP_END_DECL
 
 #include "proto-slap.h"