From ece7452b05fcbbb14823e113b683365a59f81f05 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 11 Apr 2003 01:29:28 +0000 Subject: [PATCH] More memory context tweaks --- servers/slapd/acl.c | 10 +- servers/slapd/aclparse.c | 6 +- servers/slapd/add.c | 4 +- servers/slapd/attr.c | 10 +- servers/slapd/ava.c | 5 +- servers/slapd/back-bdb/add.c | 2 +- servers/slapd/back-bdb/compare.c | 2 +- servers/slapd/back-bdb/delete.c | 2 +- servers/slapd/back-bdb/filterindex.c | 76 ++++++------- servers/slapd/back-bdb/index.c | 74 ++++++------ servers/slapd/back-bdb/modify.c | 4 +- servers/slapd/back-bdb/modrdn.c | 22 ++-- servers/slapd/back-bdb/passwd.c | 2 +- servers/slapd/back-bdb/proto-bdb.h | 8 +- servers/slapd/back-bdb/search.c | 8 +- servers/slapd/back-bdb/tools.c | 12 +- servers/slapd/back-ldap/back-ldap.h | 2 + servers/slapd/back-ldap/config.c | 4 +- servers/slapd/back-ldap/search.c | 5 +- servers/slapd/back-ldap/suffixmassage.c | 2 +- servers/slapd/back-ldbm/add.c | 2 +- servers/slapd/back-ldbm/compare.c | 3 +- servers/slapd/back-ldbm/delete.c | 2 +- servers/slapd/back-ldbm/filterindex.c | 104 ++++++++--------- servers/slapd/back-ldbm/index.c | 70 ++++++------ servers/slapd/back-ldbm/modify.c | 4 +- servers/slapd/back-ldbm/modrdn.c | 14 +-- servers/slapd/back-ldbm/passwd.c | 2 +- servers/slapd/back-ldbm/proto-back-ldbm.h | 8 +- servers/slapd/back-ldbm/search.c | 10 +- servers/slapd/back-ldbm/tools.c | 14 ++- servers/slapd/back-monitor/conn.c | 6 +- servers/slapd/back-passwd/search.c | 8 +- servers/slapd/back-sql/modify.c | 12 +- servers/slapd/backend.c | 2 +- servers/slapd/bind.c | 16 +-- servers/slapd/compare.c | 6 +- servers/slapd/config.c | 14 +-- servers/slapd/connection.c | 2 +- servers/slapd/delete.c | 2 +- servers/slapd/dn.c | 133 +++++++++++----------- servers/slapd/entry.c | 10 +- servers/slapd/filter.c | 38 ++----- servers/slapd/filterentry.c | 20 ++-- servers/slapd/limits.c | 2 +- servers/slapd/matchedValues.c | 2 +- servers/slapd/modify.c | 15 +-- servers/slapd/modrdn.c | 46 ++++---- servers/slapd/mra.c | 2 +- servers/slapd/proto-slap.h | 63 ++++------ servers/slapd/referral.c | 6 +- servers/slapd/repl.c | 2 +- servers/slapd/sasl.c | 18 +-- servers/slapd/saslauthz.c | 4 +- servers/slapd/schema_check.c | 8 +- servers/slapd/schema_init.c | 77 +++++++------ servers/slapd/schema_prep.c | 25 ++-- servers/slapd/search.c | 14 +-- servers/slapd/sl_malloc.c | 11 +- servers/slapd/slap.h | 15 ++- servers/slapd/slapi/slapi_ops.c | 16 +-- servers/slapd/slapi/slapi_utils.c | 8 +- servers/slapd/tools/Makefile.in | 2 +- servers/slapd/tools/mimic.c | 6 +- servers/slapd/tools/slapcommon.c | 2 +- servers/slapd/value.c | 14 ++- 66 files changed, 572 insertions(+), 548 deletions(-) diff --git a/servers/slapd/acl.c b/servers/slapd/acl.c index 143d53d18d..d51e3c7aaf 100644 --- a/servers/slapd/acl.c +++ b/servers/slapd/acl.c @@ -670,7 +670,7 @@ acl_mask( string_expand(&bv, &b->a_dn_pat, e->e_ndn, matches); - if ( dnNormalize2(NULL, &bv, &pat) != LDAP_SUCCESS ) { + if ( dnNormalize2(NULL, &bv, &pat, op->o_tmpmemctx ) != LDAP_SUCCESS ) { /* did not expand to a valid dn */ continue; } @@ -903,7 +903,7 @@ dn_match_cleanup:; SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, at->a_nvals, - &bv ) == 0 ) + &bv, op->o_tmpmemctx ) == 0 ) { /* found it */ match = 1; @@ -975,7 +975,7 @@ dn_match_cleanup:; bv.bv_val = buf; string_expand( &bv, &b->a_group_pat, e->e_ndn, matches ); - if ( dnNormalize2( NULL, &bv, &ndn ) != LDAP_SUCCESS ) { + if ( dnNormalize2( NULL, &bv, &ndn, op->o_tmpmemctx ) != LDAP_SUCCESS ) { /* did not expand to a valid dn */ continue; } @@ -1435,7 +1435,7 @@ aci_set_gather (void *cookie, struct berval *name, struct berval *attr) * also return the syntax or some "comparison cookie". */ - if (dnNormalize2(NULL, name, &ndn) == LDAP_SUCCESS) { + if (dnNormalize2(NULL, name, &ndn, cp->op->o_tmpmemctx ) == LDAP_SUCCESS) { const char *text; AttributeDescription *desc = NULL; if (slap_bv2ad(attr, &desc, &text) == LDAP_SUCCESS) { @@ -1483,7 +1483,7 @@ aci_match_set ( * NOTE: dnNormalize2 honors the ber_len field * as the length of the dn to be normalized */ - if ( dnNormalize2(NULL, &subjdn, &ndn) == LDAP_SUCCESS + if ( dnNormalize2(NULL, &subjdn, &ndn, op->o_tmpmemctx) == LDAP_SUCCESS && slap_bv2ad(&setat, &desc, &text) == LDAP_SUCCESS ) { backend_attribute(op, e, diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index e22f3263ec..0032846346 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -239,7 +239,7 @@ parse_acl( { if ( a->acl_dn_style != ACL_STYLE_REGEX ) { struct berval bv; - rc = dnNormalize2( NULL, &a->acl_dn_pat, &bv); + rc = dnNormalize2( NULL, &a->acl_dn_pat, &bv, NULL); if ( rc != LDAP_SUCCESS ) { fprintf( stderr, "%s: line %d: bad DN \"%s\"\n", @@ -410,7 +410,7 @@ parse_acl( } if ( sty != ACL_STYLE_REGEX && expand == 0 ) { - rc = dnNormalize2(NULL, &bv, &b->a_dn_pat); + rc = dnNormalize2(NULL, &bv, &b->a_dn_pat, NULL); if ( rc != LDAP_SUCCESS ) { fprintf( stderr, "%s: line %d: bad DN \"%s\"\n", @@ -520,7 +520,7 @@ parse_acl( b->a_group_pat = bv; } else { ber_str2bv( right, 0, 0, &bv ); - rc = dnNormalize2( NULL, &bv, &b->a_group_pat ); + rc = dnNormalize2( NULL, &bv, &b->a_group_pat, NULL ); if ( rc != LDAP_SUCCESS ) { fprintf( stderr, "%s: line %d: bad DN \"%s\"\n", diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 400f926534..376e931afc 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -78,7 +78,7 @@ do_add( Operation *op, SlapReply *rs ) e = (Entry *) ch_calloc( 1, sizeof(Entry) ); - rs->sr_err = dnPrettyNormal( NULL, &dn, &e->e_name, &e->e_nname ); + rs->sr_err = dnPrettyNormal( NULL, &dn, &e->e_name, &e->e_nname, op->o_tmpmemctx ); if( rs->sr_err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING @@ -242,7 +242,7 @@ do_add( Operation *op, SlapReply *rs ) size_t textlen = sizeof textbuf; rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text, - textbuf, textlen ); + textbuf, textlen, op->o_tmpmemctx ); if( rs->sr_err != LDAP_SUCCESS ) { send_ldap_result( op, rs ); diff --git a/servers/slapd/attr.c b/servers/slapd/attr.c index a2a009aeff..d1023d9623 100644 --- a/servers/slapd/attr.c +++ b/servers/slapd/attr.c @@ -156,7 +156,8 @@ int attr_merge_normalize( Entry *e, AttributeDescription *desc, - BerVarray vals + BerVarray vals, + void *memctx ) { BerVarray nvals = NULL; int rc; @@ -172,7 +173,7 @@ attr_merge_normalize( 0, desc->ad_type->sat_syntax, desc->ad_type->sat_equality, - &vals[i], &nvals[i] ); + &vals[i], &nvals[i], memctx ); if ( rc != LDAP_SUCCESS ) { nvals[i+1].bv_val = NULL; @@ -225,7 +226,8 @@ int attr_merge_normalize_one( Entry *e, AttributeDescription *desc, - struct berval *val + struct berval *val, + void *memctx ) { struct berval nval; int rc; @@ -235,7 +237,7 @@ attr_merge_normalize_one( 0, desc->ad_type->sat_syntax, desc->ad_type->sat_equality, - val, &nval ); + val, &nval, memctx ); if ( rc != LDAP_SUCCESS ) { return rc; diff --git a/servers/slapd/ava.c b/servers/slapd/ava.c index bf43ec5dea..0ec27edcc5 100644 --- a/servers/slapd/ava.c +++ b/servers/slapd/ava.c @@ -22,8 +22,7 @@ ava_free( int freeit ) { - /* op->o_tmpfree( ava->aa_value.bv_val, op->o_tmpmemctx ); */ - ch_free( ava->aa_value.bv_val ); + op->o_tmpfree( ava->aa_value.bv_val, op->o_tmpmemctx ); if ( freeit ) { op->o_tmpfree( (char *) ava, op->o_tmpmemctx ); } @@ -68,7 +67,7 @@ get_ava( rc = asserted_value_validate_normalize( aa->aa_desc, ad_mr(aa->aa_desc, usage), - usage, &value, &aa->aa_value, text ); + usage, &value, &aa->aa_value, text, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { op->o_tmpfree( aa, op->o_tmpmemctx ); diff --git a/servers/slapd/back-bdb/add.c b/servers/slapd/back-bdb/add.c index 2def78482c..0d919f1069 100644 --- a/servers/slapd/back-bdb/add.c +++ b/servers/slapd/back-bdb/add.c @@ -415,7 +415,7 @@ retry: /* transaction retry */ } /* attribute indexes */ - rs->sr_err = bdb_index_entry_add( op->o_bd, ltid, op->oq_add.rs_e ); + rs->sr_err = bdb_index_entry_add( op, ltid, op->oq_add.rs_e ); if ( rs->sr_err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG ( OPERATION, ERR, diff --git a/servers/slapd/back-bdb/compare.c b/servers/slapd/back-bdb/compare.c index eb928e3b5c..65b9e6de9b 100644 --- a/servers/slapd/back-bdb/compare.c +++ b/servers/slapd/back-bdb/compare.c @@ -119,7 +119,7 @@ dn2entry_retry: if ( value_find_ex( op->oq_compare.rs_ava->aa_desc, SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, - a->a_nvals, &op->oq_compare.rs_ava->aa_value ) == 0 ) + a->a_nvals, &op->oq_compare.rs_ava->aa_value, op->o_tmpmemctx ) == 0 ) { rs->sr_err = LDAP_COMPARE_TRUE; break; diff --git a/servers/slapd/back-bdb/delete.c b/servers/slapd/back-bdb/delete.c index 4d59452d7d..bb7c90def3 100644 --- a/servers/slapd/back-bdb/delete.c +++ b/servers/slapd/back-bdb/delete.c @@ -388,7 +388,7 @@ retry: /* transaction retry */ } /* delete indices for old attributes */ - rs->sr_err = bdb_index_entry_del( op->o_bd, ltid, e ); + rs->sr_err = bdb_index_entry_del( op, ltid, e ); if ( rs->sr_err != LDAP_SUCCESS ) { switch( rs->sr_err ) { case DB_LOCK_DEADLOCK: diff --git a/servers/slapd/back-bdb/filterindex.c b/servers/slapd/back-bdb/filterindex.c index 80354a7b8b..3a123b68e2 100644 --- a/servers/slapd/back-bdb/filterindex.c +++ b/servers/slapd/back-bdb/filterindex.c @@ -14,28 +14,28 @@ #include "idl.h" static int presence_candidates( - Backend *be, + Operation *op, AttributeDescription *desc, ID *ids ); static int equality_candidates( - Backend *be, + Operation *op, AttributeAssertion *ava, ID *ids, ID *tmp ); static int approx_candidates( - Backend *be, + Operation *op, AttributeAssertion *ava, ID *ids, ID *tmp ); static int substring_candidates( - Backend *be, + Operation *op, SubstringsAssertion *sub, ID *ids, ID *tmp ); static int list_candidates( - Backend *be, + Operation *op, Filter *flist, int ftype, ID *ids, @@ -44,7 +44,7 @@ static int list_candidates( int bdb_filter_candidates( - Backend *be, + Operation *op, Filter *f, ID *ids, ID *tmp, @@ -64,7 +64,7 @@ bdb_filter_candidates( #else Debug( LDAP_DEBUG_FILTER, "\tDN ONE\n", 0, 0, 0 ); #endif - rc = bdb_dn2idl( be, f->f_dn, DN_ONE_PREFIX, ids ); + rc = bdb_dn2idl( op->o_bd, f->f_dn, DN_ONE_PREFIX, ids ); if( rc == DB_NOTFOUND ) { BDB_IDL_ZERO( ids ); rc = 0; @@ -77,7 +77,7 @@ bdb_filter_candidates( #else Debug( LDAP_DEBUG_FILTER, "\tDN SUBTREE\n", 0, 0, 0 ); #endif - rc = bdb_dn2idl( be, f->f_dn, DN_SUBTREE_PREFIX, ids ); + rc = bdb_dn2idl( op->o_bd, f->f_dn, DN_SUBTREE_PREFIX, ids ); break; case LDAP_FILTER_PRESENT: @@ -86,7 +86,7 @@ bdb_filter_candidates( #else Debug( LDAP_DEBUG_FILTER, "\tPRESENT\n", 0, 0, 0 ); #endif - rc = presence_candidates( be, f->f_desc, ids ); + rc = presence_candidates( op, f->f_desc, ids ); break; case LDAP_FILTER_EQUALITY: @@ -95,7 +95,7 @@ bdb_filter_candidates( #else Debug( LDAP_DEBUG_FILTER, "\tEQUALITY\n", 0, 0, 0 ); #endif - rc = equality_candidates( be, f->f_ava, ids, tmp ); + rc = equality_candidates( op, f->f_ava, ids, tmp ); break; case LDAP_FILTER_APPROX: @@ -104,7 +104,7 @@ bdb_filter_candidates( #else Debug( LDAP_DEBUG_FILTER, "\tAPPROX\n", 0, 0, 0 ); #endif - rc = approx_candidates( be, f->f_ava, ids, tmp ); + rc = approx_candidates( op, f->f_ava, ids, tmp ); break; case LDAP_FILTER_SUBSTRINGS: @@ -113,7 +113,7 @@ bdb_filter_candidates( #else Debug( LDAP_DEBUG_FILTER, "\tSUBSTRINGS\n", 0, 0, 0 ); #endif - rc = substring_candidates( be, f->f_sub, ids, tmp ); + rc = substring_candidates( op, f->f_sub, ids, tmp ); break; case LDAP_FILTER_GE: @@ -123,7 +123,7 @@ bdb_filter_candidates( #else Debug( LDAP_DEBUG_FILTER, "\tGE\n", 0, 0, 0 ); #endif - rc = presence_candidates( be, f->f_ava->aa_desc, ids ); + rc = presence_candidates( op, f->f_ava->aa_desc, ids ); break; case LDAP_FILTER_LE: @@ -133,7 +133,7 @@ bdb_filter_candidates( #else Debug( LDAP_DEBUG_FILTER, "\tLE\n", 0, 0, 0 ); #endif - rc = presence_candidates( be, f->f_ava->aa_desc, ids ); + rc = presence_candidates( op, f->f_ava->aa_desc, ids ); break; case LDAP_FILTER_NOT: @@ -151,7 +151,7 @@ bdb_filter_candidates( #else Debug( LDAP_DEBUG_FILTER, "\tAND\n", 0, 0, 0 ); #endif - rc = list_candidates( be, + rc = list_candidates( op, f->f_and, LDAP_FILTER_AND, ids, tmp, stack ); break; @@ -161,7 +161,7 @@ bdb_filter_candidates( #else Debug( LDAP_DEBUG_FILTER, "\tOR\n", 0, 0, 0 ); #endif - rc = list_candidates( be, + rc = list_candidates( op, f->f_or, LDAP_FILTER_OR, ids, tmp, stack ); break; @@ -191,14 +191,14 @@ bdb_filter_candidates( static int list_candidates( - Backend *be, + Operation *op, Filter *flist, int ftype, ID *ids, ID *tmp, ID *save ) { - struct bdb_info *bdb = (struct bdb_info *) be->be_private; + struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private; int rc = 0; Filter *f; @@ -216,7 +216,7 @@ list_candidates( } for ( f = flist; f != NULL; f = f->f_next ) { - rc = bdb_filter_candidates( be, f, save, tmp, + rc = bdb_filter_candidates( op, f, save, tmp, save+BDB_IDL_UM_SIZE ); if ( rc != 0 ) { @@ -266,11 +266,11 @@ list_candidates( static int presence_candidates( - Backend *be, + Operation *op, AttributeDescription *desc, ID *ids ) { - struct bdb_info *bdb = (struct bdb_info *) be->be_private; + struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private; DB *db; int rc; slap_mask_t mask; @@ -289,7 +289,7 @@ presence_candidates( return 0; } - rc = bdb_index_param( be, desc, LDAP_FILTER_PRESENT, + rc = bdb_index_param( op->o_bd, desc, LDAP_FILTER_PRESENT, &db, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { @@ -334,7 +334,7 @@ presence_candidates( return 0; } - rc = bdb_key_read( be, db, NULL, &prefix, ids ); + rc = bdb_key_read( op->o_bd, db, NULL, &prefix, ids ); if( rc == DB_NOTFOUND ) { BDB_IDL_ZERO( ids ); @@ -372,7 +372,7 @@ done: static int equality_candidates( - Backend *be, + Operation *op, AttributeAssertion *ava, ID *ids, ID *tmp ) @@ -393,7 +393,7 @@ equality_candidates( ava->aa_desc->ad_cname.bv_val, 0, 0 ); #endif - rc = bdb_index_param( be, ava->aa_desc, LDAP_FILTER_EQUALITY, + rc = bdb_index_param( op->o_bd, ava->aa_desc, LDAP_FILTER_EQUALITY, &db, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { @@ -440,7 +440,7 @@ equality_candidates( mr, &prefix, &ava->aa_value, - &keys ); + &keys, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING @@ -471,7 +471,7 @@ equality_candidates( } for ( i= 0; keys[i].bv_val != NULL; i++ ) { - rc = bdb_key_read( be, db, NULL, &keys[i], tmp ); + rc = bdb_key_read( op->o_bd, db, NULL, &keys[i], tmp ); if( rc == DB_NOTFOUND ) { BDB_IDL_ZERO( ids ); @@ -511,7 +511,7 @@ equality_candidates( break; } - ber_bvarray_free( keys ); + ber_bvarray_free_x( keys, op->o_tmpmemctx ); #ifdef NEW_LOGGING LDAP_LOG ( INDEX, RESULTS, @@ -531,7 +531,7 @@ equality_candidates( static int approx_candidates( - Backend *be, + Operation *op, AttributeAssertion *ava, ID *ids, ID *tmp ) @@ -552,7 +552,7 @@ approx_candidates( ava->aa_desc->ad_cname.bv_val, 0, 0 ); #endif - rc = bdb_index_param( be, ava->aa_desc, LDAP_FILTER_APPROX, + rc = bdb_index_param( op->o_bd, ava->aa_desc, LDAP_FILTER_APPROX, &db, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { @@ -604,7 +604,7 @@ approx_candidates( mr, &prefix, &ava->aa_value, - &keys ); + &keys, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING @@ -635,7 +635,7 @@ approx_candidates( } for ( i= 0; keys[i].bv_val != NULL; i++ ) { - rc = bdb_key_read( be, db, NULL, &keys[i], tmp ); + rc = bdb_key_read( op->o_bd, db, NULL, &keys[i], tmp ); if( rc == DB_NOTFOUND ) { BDB_IDL_ZERO( ids ); @@ -676,7 +676,7 @@ approx_candidates( break; } - ber_bvarray_free( keys ); + ber_bvarray_free_x( keys, op->o_tmpmemctx ); #ifdef NEW_LOGGING LDAP_LOG ( INDEX, RESULTS, @@ -694,7 +694,7 @@ approx_candidates( static int substring_candidates( - Backend *be, + Operation *op, SubstringsAssertion *sub, ID *ids, ID *tmp ) @@ -715,7 +715,7 @@ substring_candidates( sub->sa_desc->ad_cname.bv_val, 0, 0 ); #endif - rc = bdb_index_param( be, sub->sa_desc, LDAP_FILTER_SUBSTRINGS, + rc = bdb_index_param( op->o_bd, sub->sa_desc, LDAP_FILTER_SUBSTRINGS, &db, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { @@ -763,7 +763,7 @@ substring_candidates( mr, &prefix, sub, - &keys ); + &keys, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING @@ -794,7 +794,7 @@ substring_candidates( } for ( i= 0; keys[i].bv_val != NULL; i++ ) { - rc = bdb_key_read( be, db, NULL, &keys[i], tmp ); + rc = bdb_key_read( op->o_bd, db, NULL, &keys[i], tmp ); if( rc == DB_NOTFOUND ) { BDB_IDL_ZERO( ids ); @@ -835,7 +835,7 @@ substring_candidates( break; } - ber_bvarray_free( keys ); + ber_bvarray_free_x( keys, op->o_tmpmemctx ); #ifdef NEW_LOGGING LDAP_LOG ( INDEX, RESULTS, diff --git a/servers/slapd/back-bdb/index.c b/servers/slapd/back-bdb/index.c index ec1bd89125..25f6f0099e 100644 --- a/servers/slapd/back-bdb/index.c +++ b/servers/slapd/back-bdb/index.c @@ -142,12 +142,12 @@ done: } static int indexer( - Backend *be, + Operation *op, DB_TXN *txn, struct berval *atname, BerVarray vals, ID id, - int op, + int opid, slap_mask_t mask ) { int rc, i; @@ -155,10 +155,11 @@ static int indexer( DB *db; AttributeDescription *ad = NULL; struct berval *keys; + void *mark; assert( mask ); - rc = bdb_db_cache( be, txn, atname->bv_val, &db ); + rc = bdb_db_cache( op->o_bd, txn, atname->bv_val, &db ); if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING @@ -176,8 +177,10 @@ static int indexer( rc = slap_bv2ad( atname, &ad, &text ); if( rc != LDAP_SUCCESS ) return rc; + mark = sl_mark(op->o_tmpmemctx); + if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) { - rc = bdb_key_change( be, db, txn, &presence_key, id, op ); + rc = bdb_key_change( op->o_bd, db, txn, &presence_key, id, opid ); if( rc ) { goto done; } @@ -189,17 +192,17 @@ static int indexer( mask, ad->ad_type->sat_syntax, ad->ad_type->sat_equality, - atname, vals, &keys ); + atname, vals, &keys, op->o_tmpmemctx ); if( rc == LDAP_SUCCESS && keys != NULL ) { for( i=0; keys[i].bv_val != NULL; i++ ) { - rc = bdb_key_change( be, db, txn, &keys[i], id, op ); + rc = bdb_key_change( op->o_bd, db, txn, &keys[i], id, opid ); if( rc ) { ber_bvarray_free( keys ); goto done; } } - ber_bvarray_free( keys ); + ber_bvarray_free_x( keys, op->o_tmpmemctx ); } rc = LDAP_SUCCESS; } @@ -210,17 +213,17 @@ static int indexer( mask, ad->ad_type->sat_syntax, ad->ad_type->sat_approx, - atname, vals, &keys ); + atname, vals, &keys, op->o_tmpmemctx ); if( rc == LDAP_SUCCESS && keys != NULL ) { for( i=0; keys[i].bv_val != NULL; i++ ) { - rc = bdb_key_change( be, db, txn, &keys[i], id, op ); + rc = bdb_key_change( op->o_bd, db, txn, &keys[i], id, opid ); if( rc ) { ber_bvarray_free( keys ); goto done; } } - ber_bvarray_free( keys ); + ber_bvarray_free_x( keys, op->o_tmpmemctx ); } rc = LDAP_SUCCESS; @@ -232,55 +235,56 @@ static int indexer( mask, ad->ad_type->sat_syntax, ad->ad_type->sat_substr, - atname, vals, &keys ); + atname, vals, &keys, op->o_tmpmemctx ); if( rc == LDAP_SUCCESS && keys != NULL ) { for( i=0; keys[i].bv_val != NULL; i++ ) { - bdb_key_change( be, db, txn, &keys[i], id, op ); + bdb_key_change( op->o_bd, db, txn, &keys[i], id, opid ); if( rc ) { ber_bvarray_free( keys ); goto done; } } - ber_bvarray_free( keys ); + ber_bvarray_free_x( keys, op->o_tmpmemctx ); } rc = LDAP_SUCCESS; } done: + sl_release( mark, op->o_tmpmemctx ); return rc; } static int index_at_values( - Backend *be, + Operation *op, DB_TXN *txn, AttributeType *type, struct berval *tags, BerVarray vals, ID id, - int op ) + int opid ) { int rc; slap_mask_t mask = 0; if( type->sat_sup ) { /* recurse */ - rc = index_at_values( be, txn, + rc = index_at_values( op, txn, type->sat_sup, tags, - vals, id, op ); + vals, id, opid ); if( rc ) return rc; } /* If this type has no AD, we've never used it before */ if( type->sat_ad ) { - bdb_attr_mask( be->be_private, type->sat_ad, &mask ); + bdb_attr_mask( op->o_bd->be_private, type->sat_ad, &mask ); } if( mask ) { - rc = indexer( be, txn, &type->sat_cname, - vals, id, op, + rc = indexer( op, txn, &type->sat_cname, + vals, id, opid, mask ); if( rc ) return rc; @@ -293,12 +297,12 @@ static int index_at_values( desc = ad_find_tags( type, tags ); if( desc ) { - bdb_attr_mask( be->be_private, desc, &mask ); + bdb_attr_mask( op->o_bd->be_private, desc, &mask ); } if( mask ) { - rc = indexer( be, txn, &desc->ad_cname, - vals, id, op, + rc = indexer( op, txn, &desc->ad_cname, + vals, id, opid, mask ); if( rc ) { @@ -311,27 +315,27 @@ static int index_at_values( } int bdb_index_values( - Backend *be, + Operation *op, DB_TXN *txn, AttributeDescription *desc, BerVarray vals, ID id, - int op ) + int opid ) { int rc; - rc = index_at_values( be, txn, + rc = index_at_values( op, txn, desc->ad_type, &desc->ad_tags, - vals, id, op ); + vals, id, opid ); return rc; } int bdb_index_entry( - Backend *be, + Operation *op, DB_TXN *txn, - int op, + int opid, Entry *e ) { int rc; @@ -339,17 +343,17 @@ bdb_index_entry( #ifdef NEW_LOGGING LDAP_LOG( INDEX, ENTRY, "index_entry: %s (%s) %ld\n", - op == SLAP_INDEX_ADD_OP ? "add" : "del", e->e_dn, (long) e->e_id ); + opid == SLAP_INDEX_ADD_OP ? "add" : "del", e->e_dn, (long) e->e_id ); #else Debug( LDAP_DEBUG_TRACE, "=> index_entry_%s( %ld, \"%s\" )\n", - op == SLAP_INDEX_ADD_OP ? "add" : "del", + opid == SLAP_INDEX_ADD_OP ? "add" : "del", (long) e->e_id, e->e_dn ); #endif /* add each attribute to the indexes */ for ( ; ap != NULL; ap = ap->a_next ) { - rc = bdb_index_values( be, txn, ap->a_desc, - ap->a_nvals, e->e_id, op ); + rc = bdb_index_values( op, txn, ap->a_desc, + ap->a_nvals, e->e_id, opid ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING @@ -358,7 +362,7 @@ bdb_index_entry( #else Debug( LDAP_DEBUG_TRACE, "<= index_entry_%s( %ld, \"%s\" ) failure\n", - op == SLAP_INDEX_ADD_OP ? "add" : "del", + opid == SLAP_INDEX_ADD_OP ? "add" : "del", (long) e->e_id, e->e_dn ); #endif return rc; @@ -369,7 +373,7 @@ bdb_index_entry( LDAP_LOG( INDEX, ENTRY, "index_entry: success\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= index_entry_%s( %ld, \"%s\" ) success\n", - op == SLAP_INDEX_ADD_OP ? "add" : "del", + opid == SLAP_INDEX_ADD_OP ? "add" : "del", (long) e->e_id, e->e_dn ); #endif diff --git a/servers/slapd/back-bdb/modify.c b/servers/slapd/back-bdb/modify.c index d51c091436..0d188d626e 100644 --- a/servers/slapd/back-bdb/modify.c +++ b/servers/slapd/back-bdb/modify.c @@ -207,7 +207,7 @@ int bdb_modify_internal( /* start with deleting the old index entries */ for ( ap = save_attrs; ap != NULL; ap = ap->a_next ) { if ( ap->a_flags & SLAP_ATTR_IXDEL ) { - rc = bdb_index_values( op->o_bd, tid, ap->a_desc, + rc = bdb_index_values( op, tid, ap->a_desc, ap->a_nvals, e->e_id, SLAP_INDEX_DELETE_OP ); if ( rc != LDAP_SUCCESS ) { @@ -231,7 +231,7 @@ int bdb_modify_internal( /* add the new index entries */ for ( ap = e->e_attrs; ap != NULL; ap = ap->a_next ) { if (ap->a_flags & SLAP_ATTR_IXADD) { - rc = bdb_index_values( op->o_bd, tid, ap->a_desc, + rc = bdb_index_values( op, tid, ap->a_desc, ap->a_nvals, e->e_id, SLAP_INDEX_ADD_OP ); if ( rc != LDAP_SUCCESS ) { diff --git a/servers/slapd/back-bdb/modrdn.c b/servers/slapd/back-bdb/modrdn.c index e723a47321..01734bb183 100644 --- a/servers/slapd/back-bdb/modrdn.c +++ b/servers/slapd/back-bdb/modrdn.c @@ -26,8 +26,8 @@ bdb_modrdn( Operation *op, SlapReply *rs ) Entry *p = NULL; Entry *matched; /* LDAP v2 supporting correct attribute handling. */ - LDAPRDN *new_rdn = NULL; - LDAPRDN *old_rdn = NULL; + LDAPRDN new_rdn = NULL; + LDAPRDN old_rdn = NULL; char textbuf[SLAP_TEXT_BUFLEN]; size_t textlen = sizeof textbuf; DB_TXN * ltid = NULL; @@ -647,7 +647,7 @@ retry: /* transaction retry */ /* Build target dn and make sure target entry doesn't exist already. */ if (!new_dn.bv_val) build_new_dn( &new_dn, new_parent_dn, &op->oq_modrdn.rs_newrdn ); - if (!new_ndn.bv_val) dnNormalize2( NULL, &new_dn, &new_ndn ); + if (!new_ndn.bv_val) dnNormalize2( NULL, &new_dn, &new_ndn, op->o_tmpmemctx ); #ifdef NEW_LOGGING LDAP_LOG ( OPERATION, RESULTS, @@ -676,8 +676,8 @@ retry: /* transaction retry */ /* Get attribute type and attribute value of our new rdn, we will * need to add that to our new entry */ - if ( !new_rdn && ldap_bv2rdn( &op->oq_modrdn.rs_newrdn, &new_rdn, (char **)&rs->sr_text, - LDAP_DN_FORMAT_LDAP ) ) + if ( !new_rdn && ldap_bv2rdn_x( &op->oq_modrdn.rs_newrdn, &new_rdn, (char **)&rs->sr_text, + LDAP_DN_FORMAT_LDAP, op->o_tmpmemctx ) ) { #ifdef NEW_LOGGING LDAP_LOG ( OPERATION, ERR, @@ -699,19 +699,19 @@ retry: /* transaction retry */ LDAP_LOG ( OPERATION, RESULTS, "bdb_modrdn: new_rdn_type=\"%s\", " "new_rdn_val=\"%s\"\n", - new_rdn[ 0 ][ 0 ]->la_attr.bv_val, - new_rdn[ 0 ][ 0 ]->la_value.bv_val, 0 ); + new_rdn[ 0 ]->la_attr.bv_val, + new_rdn[ 0 ]->la_value.bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "bdb_modrdn: new_rdn_type=\"%s\", " "new_rdn_val=\"%s\"\n", - new_rdn[ 0 ][ 0 ]->la_attr.bv_val, - new_rdn[ 0 ][ 0 ]->la_value.bv_val, 0 ); + new_rdn[ 0 ]->la_attr.bv_val, + new_rdn[ 0 ]->la_value.bv_val, 0 ); #endif if ( op->oq_modrdn.rs_deleteoldrdn ) { - if ( !old_rdn && ldap_bv2rdn( &op->o_req_dn, &old_rdn, (char **)&rs->sr_text, - LDAP_DN_FORMAT_LDAP ) ) + if ( !old_rdn && ldap_bv2rdn_x( &op->o_req_dn, &old_rdn, (char **)&rs->sr_text, + LDAP_DN_FORMAT_LDAP, op->o_tmpmemctx ) ) { #ifdef NEW_LOGGING LDAP_LOG ( OPERATION, ERR, diff --git a/servers/slapd/back-bdb/passwd.c b/servers/slapd/back-bdb/passwd.c index 42aa31eb78..2e21acf9d6 100644 --- a/servers/slapd/back-bdb/passwd.c +++ b/servers/slapd/back-bdb/passwd.c @@ -92,7 +92,7 @@ bdb_exop_passwd( Operation *op, SlapReply *rs ) goto done; } - rc = dnNormalize2( NULL, &dn, &ndn ); + rc = dnNormalize2( NULL, &dn, &ndn, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { rs->sr_text = "Invalid DN"; goto done; diff --git a/servers/slapd/back-bdb/proto-bdb.h b/servers/slapd/back-bdb/proto-bdb.h index 4fd7d8a75f..74e455bddb 100644 --- a/servers/slapd/back-bdb/proto-bdb.h +++ b/servers/slapd/back-bdb/proto-bdb.h @@ -119,7 +119,7 @@ void bdb_errcall( const char *pfx, char * msg ); * filterentry.c */ int bdb_filter_candidates( - Backend *be, + Operation *op, Filter *f, ID *ids, ID *tmp, @@ -236,14 +236,14 @@ bdb_index_param LDAP_P(( extern int bdb_index_values LDAP_P(( - Backend *be, + Operation *op, DB_TXN *txn, AttributeDescription *desc, BerVarray vals, ID id, - int op )); + int opid )); -int bdb_index_entry LDAP_P(( Backend *be, DB_TXN *t, int r, Entry *e )); +int bdb_index_entry LDAP_P(( Operation *op, DB_TXN *t, int r, Entry *e )); #define bdb_index_entry_add(be,t,e) \ bdb_index_entry((be),(t),SLAP_INDEX_ADD_OP,(e)) diff --git a/servers/slapd/back-bdb/search.c b/servers/slapd/back-bdb/search.c index 38b087017e..595a65b0f6 100644 --- a/servers/slapd/back-bdb/search.c +++ b/servers/slapd/back-bdb/search.c @@ -157,7 +157,7 @@ static int search_aliases( /* Find all aliases in database */ BDB_IDL_ALL( bdb, aliases ); - rs->sr_err = bdb_filter_candidates( op->o_bd, &af, aliases, + rs->sr_err = bdb_filter_candidates( op, &af, aliases, curscop, visited ); if (rs->sr_err != LDAP_SUCCESS) { return rs->sr_err; @@ -179,7 +179,7 @@ static int search_aliases( * to the cumulative list of candidates. */ BDB_IDL_CPY( curscop, aliases ); - rs->sr_err = bdb_filter_candidates( op->o_bd, sf, subscop, NULL, NULL ); + rs->sr_err = bdb_filter_candidates( op, sf, subscop, NULL, NULL ); if (first) { first = 0; } else { @@ -1525,12 +1525,12 @@ static int search_candidates( if( op->ors_deref & LDAP_DEREF_SEARCHING ) { rc = search_aliases( op, rs, e, locker, &scopef, ids, stack ); } else { - rc = bdb_filter_candidates( op->o_bd, &scopef, ids, + rc = bdb_filter_candidates( op, &scopef, ids, stack, stack+BDB_IDL_UM_SIZE ); } if ( rc == LDAP_SUCCESS ) { - rc = bdb_filter_candidates( op->o_bd, &f, ids, + rc = bdb_filter_candidates( op, &f, ids, stack, stack+BDB_IDL_UM_SIZE ); } diff --git a/servers/slapd/back-bdb/tools.c b/servers/slapd/back-bdb/tools.c index d95ca4640c..f0da2f8662 100644 --- a/servers/slapd/back-bdb/tools.c +++ b/servers/slapd/back-bdb/tools.c @@ -220,6 +220,7 @@ ID bdb_tool_entry_put( struct bdb_info *bdb = (struct bdb_info *) be->be_private; DB_TXN *tid = NULL; struct berval pdn; + Operation op = {0}; assert( be != NULL ); assert( slapMode & SLAP_TOOL_MODE ); @@ -274,7 +275,10 @@ ID bdb_tool_entry_put( goto done; } - rc = bdb_index_entry_add( be, tid, e ); + op.o_bd = be; + op.o_tmpmemctx = NULL; + op.o_tmpmfuncs = &ch_mfuncs; + rc = bdb_index_entry_add( &op, tid, e ); if( rc != 0 ) { snprintf( text->bv_val, text->bv_len, "index_entry_add failed: %s (%d)", @@ -335,6 +339,7 @@ int bdb_tool_entry_reindex( Entry *e; DB_TXN *tid = NULL; struct berval pdn; + Operation op = {0}; #ifdef NEW_LOGGING LDAP_LOG ( TOOLS, ARGS, @@ -408,7 +413,10 @@ int bdb_tool_entry_reindex( goto done; } - rc = bdb_index_entry_add( be, tid, e ); + op.o_bd = be; + op.o_tmpmemctx = NULL; + op.o_tmpmfuncs = &ch_mfuncs; + rc = bdb_index_entry_add( &op, tid, e ); done: if( rc == 0 ) { diff --git a/servers/slapd/back-ldap/back-ldap.h b/servers/slapd/back-ldap/back-ldap.h index dc67f7e158..69dbb81948 100644 --- a/servers/slapd/back-ldap/back-ldap.h +++ b/servers/slapd/back-ldap/back-ldap.h @@ -40,6 +40,8 @@ #include "external.h" +#undef ENABLE_REWRITE + /* String rewrite library */ #ifdef ENABLE_REWRITE #include "rewrite.h" diff --git a/servers/slapd/back-ldap/config.c b/servers/slapd/back-ldap/config.c index 80fca89905..3c997e7e79 100644 --- a/servers/slapd/back-ldap/config.c +++ b/servers/slapd/back-ldap/config.c @@ -162,7 +162,7 @@ ldap_back_db_config( } ber_str2bv( argv[1], 0, 0, &bvnc ); - if ( dnPrettyNormal( NULL, &bvnc, &pvnc, &nvnc ) != LDAP_SUCCESS ) { + if ( dnPrettyNormal( NULL, &bvnc, &pvnc, &nvnc, NULL ) != LDAP_SUCCESS ) { fprintf( stderr, "%s: line %d: suffix DN %s is invalid\n", fname, lineno, bvnc.bv_val ); return( 1 ); @@ -180,7 +180,7 @@ ldap_back_db_config( } ber_str2bv( argv[2], 0, 0, &brnc ); - if ( dnPrettyNormal( NULL, &brnc, &prnc, &nrnc ) != LDAP_SUCCESS ) { + if ( dnPrettyNormal( NULL, &brnc, &prnc, &nrnc, NULL ) != LDAP_SUCCESS ) { fprintf( stderr, "%s: line %d: suffix DN %s is invalid\n", fname, lineno, brnc.bv_val ); free( nvnc.bv_val ); diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index c9827ae247..0015670816 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -408,7 +408,7 @@ ldap_build_entry( * * FIXME: should we log anything, or delegate to dnNormalize2? */ - if ( dnNormalize2( NULL, &ent->e_name, &ent->e_nname ) != LDAP_SUCCESS ) { + if ( dnNormalize2( NULL, &ent->e_name, &ent->e_nname, op->o_tmpmemctx ) != LDAP_SUCCESS ) { return LDAP_INVALID_DN_SYNTAX; } @@ -533,7 +533,8 @@ ldap_build_entry( SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX, attr->a_desc->ad_type->sat_syntax, attr->a_desc->ad_type->sat_equality, - &attr->a_vals[i], &attr->a_nvals[i] ); + &attr->a_vals[i], &attr->a_nvals[i], + op->o_tmpmemctx ); } attr->a_nvals[i].bv_val = NULL; attr->a_nvals[i].bv_len = 0; diff --git a/servers/slapd/back-ldap/suffixmassage.c b/servers/slapd/back-ldap/suffixmassage.c index 81b1debc33..411a9051f8 100644 --- a/servers/slapd/back-ldap/suffixmassage.c +++ b/servers/slapd/back-ldap/suffixmassage.c @@ -121,7 +121,7 @@ ldap_back_dn_massage( /* DN from remote server may be in arbitrary form. * Pretty it so we can parse reliably. */ - dnPretty2( NULL, dn, &pretty ); + dnPretty2( NULL, dn, &pretty, NULL ); if (pretty.bv_val) dn = &pretty; } diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index a5cbdcb451..52aa5a5d3f 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -338,7 +338,7 @@ ldbm_back_add( rs->sr_err = -1; /* attribute indexes */ - if ( index_entry_add( op->o_bd, op->oq_add.rs_e ) != LDAP_SUCCESS ) { + if ( index_entry_add( op, op->oq_add.rs_e ) != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG( BACK_LDBM, ERR, "ldbm_back_add: index_entry_add failed.\n", 0, 0, 0 ); diff --git a/servers/slapd/back-ldbm/compare.c b/servers/slapd/back-ldbm/compare.c index 155a022b4c..0f560e59d1 100644 --- a/servers/slapd/back-ldbm/compare.c +++ b/servers/slapd/back-ldbm/compare.c @@ -97,7 +97,8 @@ ldbm_back_compare( if ( value_find_ex( op->oq_compare.rs_ava->aa_desc, SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, - a->a_nvals, &op->oq_compare.rs_ava->aa_value ) == 0 ) + a->a_nvals, &op->oq_compare.rs_ava->aa_value, + op->o_tmpmemctx ) == 0 ) { rs->sr_err = LDAP_COMPARE_TRUE; break; diff --git a/servers/slapd/back-ldbm/delete.c b/servers/slapd/back-ldbm/delete.c index 0ab46b74d7..3317f40c37 100644 --- a/servers/slapd/back-ldbm/delete.c +++ b/servers/slapd/back-ldbm/delete.c @@ -252,7 +252,7 @@ ldbm_back_delete( } /* delete attribute indices */ - (void) index_entry_del( op->o_bd, e ); + (void) index_entry_del( op, e ); rs->sr_err = LDAP_SUCCESS; send_ldap_result( op, rs ); diff --git a/servers/slapd/back-ldbm/filterindex.c b/servers/slapd/back-ldbm/filterindex.c index ff07968cd9..f019e17652 100644 --- a/servers/slapd/back-ldbm/filterindex.c +++ b/servers/slapd/back-ldbm/filterindex.c @@ -16,23 +16,23 @@ #include "back-ldbm.h" static ID_BLOCK *presence_candidates( - Backend *be, + Operation *op, AttributeDescription *desc ); static ID_BLOCK *equality_candidates( - Backend *be, AttributeAssertion *ava ); + Operation *op, AttributeAssertion *ava ); static ID_BLOCK *approx_candidates( - Backend *be, AttributeAssertion *ava ); + Operation *op, AttributeAssertion *ava ); static ID_BLOCK *substring_candidates( - Backend *be, + Operation *op, SubstringsAssertion *sub ); static ID_BLOCK *list_candidates( - Backend *be, + Operation *op, Filter *flist, int ftype ); ID_BLOCK * filter_candidates( - Backend *be, + Operation *op, Filter *f ) { @@ -56,7 +56,7 @@ filter_candidates( #endif /* an error is treated as an empty list */ - if ( dn2idl( be, f->f_dn, DN_ONE_PREFIX, &result ) != 0 + if ( dn2idl( op->o_bd, f->f_dn, DN_ONE_PREFIX, &result ) != 0 && result != NULL ) { idl_free( result ); result = NULL; @@ -72,7 +72,7 @@ filter_candidates( #endif /* an error is treated as an empty list */ - if ( dn2idl( be, f->f_dn, DN_SUBTREE_PREFIX, &result ) != 0 + if ( dn2idl( op->o_bd, f->f_dn, DN_SUBTREE_PREFIX, &result ) != 0 && result != NULL ) { idl_free( result ); result = NULL; @@ -88,7 +88,7 @@ filter_candidates( Debug( LDAP_DEBUG_FILTER, "\tPRESENT\n", 0, 0, 0 ); #endif - result = presence_candidates( be, f->f_desc ); + result = presence_candidates( op, f->f_desc ); break; case LDAP_FILTER_EQUALITY: @@ -101,7 +101,7 @@ filter_candidates( Debug( LDAP_DEBUG_FILTER, "\tEQUALITY\n", 0, 0, 0 ); #endif - result = equality_candidates( be, f->f_ava ); + result = equality_candidates( op, f->f_ava ); break; case LDAP_FILTER_APPROX: @@ -114,7 +114,7 @@ filter_candidates( Debug( LDAP_DEBUG_FILTER, "\tAPPROX\n", 0, 0, 0 ); #endif - result = approx_candidates( be, f->f_ava ); + result = approx_candidates( op, f->f_ava ); break; case LDAP_FILTER_SUBSTRINGS: @@ -125,7 +125,7 @@ filter_candidates( Debug( LDAP_DEBUG_FILTER, "\tSUBSTRINGS\n", 0, 0, 0 ); #endif - result = substring_candidates( be, f->f_sub ); + result = substring_candidates( op, f->f_sub ); break; case LDAP_FILTER_GE: @@ -135,7 +135,7 @@ filter_candidates( Debug( LDAP_DEBUG_FILTER, "\tGE\n", 0, 0, 0 ); #endif - result = presence_candidates( be, f->f_ava->aa_desc ); + result = presence_candidates( op, f->f_ava->aa_desc ); break; case LDAP_FILTER_LE: @@ -145,7 +145,7 @@ filter_candidates( Debug( LDAP_DEBUG_FILTER, "\tLE\n", 0, 0, 0 ); #endif - result = presence_candidates( be, f->f_ava->aa_desc ); + result = presence_candidates( op, f->f_ava->aa_desc ); break; case LDAP_FILTER_AND: @@ -155,7 +155,7 @@ filter_candidates( Debug( LDAP_DEBUG_FILTER, "\tAND\n", 0, 0, 0 ); #endif - result = list_candidates( be, f->f_and, LDAP_FILTER_AND ); + result = list_candidates( op, f->f_and, LDAP_FILTER_AND ); break; case LDAP_FILTER_OR: @@ -165,7 +165,7 @@ filter_candidates( Debug( LDAP_DEBUG_FILTER, "\tOR\n", 0, 0, 0 ); #endif - result = list_candidates( be, f->f_or, LDAP_FILTER_OR ); + result = list_candidates( op, f->f_or, LDAP_FILTER_OR ); break; case LDAP_FILTER_NOT: @@ -181,7 +181,7 @@ filter_candidates( * list could result in matching entries be excluded from * the returned candidate list. */ - result = idl_allids( be ); + result = idl_allids( op->o_bd ); break; default: #ifdef NEW_LOGGING @@ -192,7 +192,7 @@ filter_candidates( /* unknown filters must not return NULL, to allow * extended filter processing to be done later. */ - result = idl_allids( be ); + result = idl_allids( op->o_bd ); break; } @@ -210,7 +210,7 @@ filter_candidates( static ID_BLOCK * presence_candidates( - Backend *be, + Operation *op, AttributeDescription *desc ) { @@ -227,13 +227,13 @@ presence_candidates( Debug( LDAP_DEBUG_TRACE, "=> presence_candidates\n", 0, 0, 0 ); #endif - idl = idl_allids( be ); + idl = idl_allids( op->o_bd ); if( desc == slap_schema.si_ad_objectClass ) { return idl; } - rc = index_param( be, desc, LDAP_FILTER_PRESENT, + rc = index_param( op->o_bd, desc, LDAP_FILTER_PRESENT, &dbname, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { @@ -262,7 +262,7 @@ presence_candidates( return idl; } - db = ldbm_cache_open( be, dbname, LDBM_SUFFIX, LDBM_WRCREAT ); + db = ldbm_cache_open( op->o_bd, dbname, LDBM_SUFFIX, LDBM_WRCREAT ); if ( db == NULL ) { #ifdef NEW_LOGGING @@ -282,7 +282,7 @@ presence_candidates( idl_free( idl ); idl = NULL; - rc = key_read( be, db, &prefix, &idl ); + rc = key_read( op->o_bd, db, &prefix, &idl ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING @@ -307,7 +307,7 @@ presence_candidates( } } - ldbm_cache_close( be, db ); + ldbm_cache_close( op->o_bd, db ); #ifdef NEW_LOGGING LDAP_LOG( FILTER, ENTRY, @@ -323,7 +323,7 @@ presence_candidates( static ID_BLOCK * equality_candidates( - Backend *be, + Operation *op, AttributeAssertion *ava ) { @@ -344,9 +344,9 @@ equality_candidates( #endif - idl = idl_allids( be ); + idl = idl_allids( op->o_bd ); - rc = index_param( be, ava->aa_desc, LDAP_FILTER_EQUALITY, + rc = index_param( op->o_bd, ava->aa_desc, LDAP_FILTER_EQUALITY, &dbname, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { @@ -391,7 +391,7 @@ equality_candidates( mr, &prefix, &ava->aa_value, - &keys ); + &keys, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING @@ -420,7 +420,7 @@ equality_candidates( return idl; } - db = ldbm_cache_open( be, dbname, LDBM_SUFFIX, LDBM_WRCREAT ); + db = ldbm_cache_open( op->o_bd, dbname, LDBM_SUFFIX, LDBM_WRCREAT ); if ( db == NULL ) { #ifdef NEW_LOGGING @@ -439,7 +439,7 @@ equality_candidates( ID_BLOCK *save; ID_BLOCK *tmp; - rc = key_read( be, db, &keys[i], &tmp ); + rc = key_read( op->o_bd, db, &keys[i], &tmp ); if( rc != LDAP_SUCCESS ) { idl_free( idl ); @@ -471,7 +471,7 @@ equality_candidates( } save = idl; - idl = idl_intersection( be, idl, tmp ); + idl = idl_intersection( op->o_bd, idl, tmp ); idl_free( save ); idl_free( tmp ); @@ -480,7 +480,7 @@ equality_candidates( ber_bvarray_free( keys ); - ldbm_cache_close( be, db ); + ldbm_cache_close( op->o_bd, db ); #ifdef NEW_LOGGING @@ -497,7 +497,7 @@ equality_candidates( static ID_BLOCK * approx_candidates( - Backend *be, + Operation *op, AttributeAssertion *ava ) { @@ -518,9 +518,9 @@ approx_candidates( #endif - idl = idl_allids( be ); + idl = idl_allids( op->o_bd ); - rc = index_param( be, ava->aa_desc, LDAP_FILTER_APPROX, + rc = index_param( op->o_bd, ava->aa_desc, LDAP_FILTER_APPROX, &dbname, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { @@ -570,7 +570,7 @@ approx_candidates( mr, &prefix, &ava->aa_value, - &keys ); + &keys, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING @@ -600,7 +600,7 @@ approx_candidates( return idl; } - db = ldbm_cache_open( be, dbname, LDBM_SUFFIX, LDBM_WRCREAT ); + db = ldbm_cache_open( op->o_bd, dbname, LDBM_SUFFIX, LDBM_WRCREAT ); if ( db == NULL ) { #ifdef NEW_LOGGING @@ -620,7 +620,7 @@ approx_candidates( ID_BLOCK *save; ID_BLOCK *tmp; - rc = key_read( be, db, &keys[i], &tmp ); + rc = key_read( op->o_bd, db, &keys[i], &tmp ); if( rc != LDAP_SUCCESS ) { idl_free( idl ); @@ -650,7 +650,7 @@ approx_candidates( } save = idl; - idl = idl_intersection( be, idl, tmp ); + idl = idl_intersection( op->o_bd, idl, tmp ); idl_free( save ); idl_free( tmp ); @@ -659,7 +659,7 @@ approx_candidates( ber_bvarray_free( keys ); - ldbm_cache_close( be, db ); + ldbm_cache_close( op->o_bd, db ); #ifdef NEW_LOGGING LDAP_LOG( FILTER, ENTRY, @@ -675,7 +675,7 @@ approx_candidates( static ID_BLOCK * list_candidates( - Backend *be, + Operation *op, Filter *flist, int ftype ) @@ -692,7 +692,7 @@ list_candidates( idl = NULL; for ( f = flist; f != NULL; f = f->f_next ) { - if ( (tmp = filter_candidates( be, f )) == NULL && + if ( (tmp = filter_candidates( op, f )) == NULL && ftype == LDAP_FILTER_AND ) { #ifdef NEW_LOGGING LDAP_LOG( FILTER, INFO, "list_candidates: NULL\n", 0, 0, 0 ); @@ -709,11 +709,11 @@ list_candidates( if ( idl == NULL ) { idl = tmp; } else if ( ftype == LDAP_FILTER_AND ) { - idl = idl_intersection( be, idl, tmp ); + idl = idl_intersection( op->o_bd, idl, tmp ); idl_free( tmp ); idl_free( tmp2 ); } else { - idl = idl_union( be, idl, tmp ); + idl = idl_union( op->o_bd, idl, tmp ); idl_free( tmp ); idl_free( tmp2 ); } @@ -732,7 +732,7 @@ list_candidates( static ID_BLOCK * substring_candidates( - Backend *be, + Operation *op, SubstringsAssertion *sub ) { @@ -753,9 +753,9 @@ substring_candidates( #endif - idl = idl_allids( be ); + idl = idl_allids( op->o_bd ); - rc = index_param( be, sub->sa_desc, LDAP_FILTER_SUBSTRINGS, + rc = index_param( op->o_bd, sub->sa_desc, LDAP_FILTER_SUBSTRINGS, &dbname, &mask, &prefix ); if( rc != LDAP_SUCCESS ) { @@ -801,7 +801,7 @@ substring_candidates( mr, &prefix, sub, - &keys ); + &keys, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING @@ -831,7 +831,7 @@ substring_candidates( return idl; } - db = ldbm_cache_open( be, dbname, LDBM_SUFFIX, LDBM_WRCREAT ); + db = ldbm_cache_open( op->o_bd, dbname, LDBM_SUFFIX, LDBM_WRCREAT ); if ( db == NULL ) { #ifdef NEW_LOGGING @@ -851,7 +851,7 @@ substring_candidates( ID_BLOCK *save; ID_BLOCK *tmp; - rc = key_read( be, db, &keys[i], &tmp ); + rc = key_read( op->o_bd, db, &keys[i], &tmp ); if( rc != LDAP_SUCCESS ) { idl_free( idl ); @@ -881,7 +881,7 @@ substring_candidates( } save = idl; - idl = idl_intersection( be, idl, tmp ); + idl = idl_intersection( op->o_bd, idl, tmp ); idl_free( save ); idl_free( tmp ); @@ -890,7 +890,7 @@ substring_candidates( ber_bvarray_free( keys ); - ldbm_cache_close( be, db ); + ldbm_cache_close( op->o_bd, db ); #ifdef NEW_LOGGING LDAP_LOG( FILTER, ENTRY, diff --git a/servers/slapd/back-ldbm/index.c b/servers/slapd/back-ldbm/index.c index 2680fb0abc..00e6c6a375 100644 --- a/servers/slapd/back-ldbm/index.c +++ b/servers/slapd/back-ldbm/index.c @@ -136,12 +136,12 @@ done: } static int indexer( - Backend *be, + Operation *op, char *dbname, struct berval *atname, BerVarray vals, ID id, - int op, + int opid, slap_mask_t mask ) { int rc, i; @@ -149,6 +149,7 @@ static int indexer( DBCache *db; AttributeDescription *ad = NULL; struct berval *keys; + void *mark; assert( mask ); @@ -156,7 +157,7 @@ static int indexer( if( rc != LDAP_SUCCESS ) return rc; - db = ldbm_cache_open( be, dbname, LDBM_SUFFIX, LDBM_WRCREAT ); + db = ldbm_cache_open( op->o_bd, dbname, LDBM_SUFFIX, LDBM_WRCREAT ); if ( db == NULL ) { #ifdef NEW_LOGGING @@ -171,8 +172,10 @@ static int indexer( return LDAP_OTHER; } + mark = sl_mark( op->o_tmpmemctx ); + if( IS_SLAP_INDEX( mask, SLAP_INDEX_PRESENT ) ) { - key_change( be, db, atname, id, op ); + key_change( op->o_bd, db, atname, id, opid ); } if( IS_SLAP_INDEX( mask, SLAP_INDEX_EQUALITY ) ) { @@ -181,11 +184,11 @@ static int indexer( mask, ad->ad_type->sat_syntax, ad->ad_type->sat_equality, - atname, vals, &keys ); + atname, vals, &keys, op->o_tmpmemctx ); if( rc == LDAP_SUCCESS && keys != NULL ) { for( i=0; keys[i].bv_val != NULL; i++ ) { - key_change( be, db, &keys[i], id, op ); + key_change( op->o_bd, db, &keys[i], id, opid ); } ber_bvarray_free( keys ); } @@ -197,11 +200,11 @@ static int indexer( mask, ad->ad_type->sat_syntax, ad->ad_type->sat_approx, - atname, vals, &keys ); + atname, vals, &keys, op->o_tmpmemctx ); if( rc == LDAP_SUCCESS && keys != NULL ) { for( i=0; keys[i].bv_val != NULL; i++ ) { - key_change( be, db, &keys[i], id, op ); + key_change( op->o_bd, db, &keys[i], id, opid ); } ber_bvarray_free( keys ); } @@ -213,46 +216,49 @@ static int indexer( mask, ad->ad_type->sat_syntax, ad->ad_type->sat_substr, - atname, vals, &keys ); + atname, vals, &keys, op->o_tmpmemctx ); if( rc == LDAP_SUCCESS && keys != NULL ) { for( i=0; keys[i].bv_val != NULL; i++ ) { - key_change( be, db, &keys[i], id, op ); + key_change( op->o_bd, db, &keys[i], id, opid ); } ber_bvarray_free( keys ); } } - ldbm_cache_close( be, db ); + ldbm_cache_close( op->o_bd, db ); + + sl_release( mark, op->o_tmpmemctx ); + return LDAP_SUCCESS; } static int index_at_values( - Backend *be, + Operation *op, AttributeType *type, struct berval *tags, BerVarray vals, ID id, - int op ) + int opid ) { slap_mask_t mask = 0; if( type->sat_sup ) { /* recurse */ - (void) index_at_values( be, + (void) index_at_values( op, type->sat_sup, tags, - vals, id, op ); + vals, id, opid ); } /* If this type has no AD, we've never used it before */ if( type->sat_ad ) { - attr_mask( be->be_private, type->sat_ad, &mask ); + attr_mask( op->o_bd->be_private, type->sat_ad, &mask ); } if( mask ) { - indexer( be, type->sat_cname.bv_val, + indexer( op, type->sat_cname.bv_val, &type->sat_cname, - vals, id, op, + vals, id, opid, mask ); } @@ -263,12 +269,12 @@ static int index_at_values( desc = ad_find_tags(type, tags); if( desc ) { - attr_mask( be->be_private, desc, &mask ); + attr_mask( op->o_bd->be_private, desc, &mask ); } if( mask ) { - indexer( be, desc->ad_cname.bv_val, &desc->ad_cname, - vals, id, op, + indexer( op, desc->ad_cname.bv_val, &desc->ad_cname, + vals, id, opid, mask ); } } @@ -277,48 +283,48 @@ static int index_at_values( } int index_values( - Backend *be, + Operation *op, AttributeDescription *desc, BerVarray vals, ID id, - int op ) + int opid ) { - (void) index_at_values( be, + (void) index_at_values( op, desc->ad_type, &desc->ad_tags, - vals, id, op ); + vals, id, opid ); return LDAP_SUCCESS; } int index_entry( - Backend *be, - int op, + Operation *op, + int opid, Entry *e ) { Attribute *ap = e->e_attrs; #ifdef NEW_LOGGING LDAP_LOG( INDEX, ENTRY, - "index_entry: %s (%s)%ld\n", op == SLAP_INDEX_ADD_OP ? "add" : "del", + "index_entry: %s (%s)%ld\n", opid == SLAP_INDEX_ADD_OP ? "add" : "del", e->e_dn, e->e_id ); #else Debug( LDAP_DEBUG_TRACE, "=> index_entry_%s( %ld, \"%s\" )\n", - op == SLAP_INDEX_ADD_OP ? "add" : "del", + opid == SLAP_INDEX_ADD_OP ? "add" : "del", e->e_id, e->e_dn ); #endif /* add each attribute to the indexes */ for ( ; ap != NULL; ap = ap->a_next ) { - index_values( be, ap->a_desc, + index_values( op, ap->a_desc, ap->a_nvals, - e->e_id, op ); + e->e_id, opid ); } #ifdef NEW_LOGGING LDAP_LOG( INDEX, ENTRY, "index_entry: success\n", 0, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "<= index_entry_%s( %ld, \"%s\" ) success\n", - op == SLAP_INDEX_ADD_OP ? "add" : "del", + opid == SLAP_INDEX_ADD_OP ? "add" : "del", e->e_id, e->e_dn ); #endif diff --git a/servers/slapd/back-ldbm/modify.c b/servers/slapd/back-ldbm/modify.c index 46ca1025a9..b044b7ffde 100644 --- a/servers/slapd/back-ldbm/modify.c +++ b/servers/slapd/back-ldbm/modify.c @@ -222,7 +222,7 @@ int ldbm_modify_internal( /* start with deleting the old index entries */ for ( ap = save_attrs; ap != NULL; ap = ap->a_next ) { if ( ap->a_flags & SLAP_ATTR_IXDEL ) { - rc = index_values( op->o_bd, ap->a_desc, + rc = index_values( op, ap->a_desc, ap->a_nvals, e->e_id, SLAP_INDEX_DELETE_OP ); if ( rc != LDAP_SUCCESS ) { @@ -244,7 +244,7 @@ int ldbm_modify_internal( /* add the new index entries */ for ( ap = e->e_attrs; ap != NULL; ap = ap->a_next ) { if ( ap->a_flags & SLAP_ATTR_IXADD ) { - rc = index_values( op->o_bd, ap->a_desc, + rc = index_values( op, ap->a_desc, ap->a_nvals, e->e_id, SLAP_INDEX_ADD_OP ); if ( rc != LDAP_SUCCESS ) { diff --git a/servers/slapd/back-ldbm/modrdn.c b/servers/slapd/back-ldbm/modrdn.c index de0d99b886..41db98229b 100644 --- a/servers/slapd/back-ldbm/modrdn.c +++ b/servers/slapd/back-ldbm/modrdn.c @@ -45,8 +45,8 @@ ldbm_back_modrdn( Entry *e, *p = NULL; Entry *matched; /* LDAP v2 supporting correct attribute handling. */ - LDAPRDN *new_rdn = NULL; - LDAPRDN *old_rdn = NULL; + LDAPRDN new_rdn = NULL; + LDAPRDN old_rdn = NULL; int isroot = -1; #define CAN_ROLLBACK -1 #define MUST_DESTROY 1 @@ -466,7 +466,7 @@ ldbm_back_modrdn( /* Build target dn and make sure target entry doesn't exist already. */ build_new_dn( &new_dn, new_parent_dn, &op->oq_modrdn.rs_newrdn ); - dnNormalize2( NULL, &new_dn, &new_ndn ); + dnNormalize2( NULL, &new_dn, &new_ndn, op->o_tmpmemctx ); #ifdef NEW_LOGGING LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_back_modrdn: new ndn=%s\n", @@ -521,14 +521,14 @@ ldbm_back_modrdn( LDAP_LOG ( OPERATION, RESULTS, "ldbm_back_modrdn: new_rdn_type=\"%s\", " "new_rdn_val=\"%s\"\n", - new_rdn[ 0 ][ 0 ]->la_attr.bv_val, - new_rdn[ 0 ][ 0 ]->la_value.bv_val, 0 ); + new_rdn[ 0 ]->la_attr.bv_val, + new_rdn[ 0 ]->la_value.bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "ldbm_back_modrdn: new_rdn_type=\"%s\", " "new_rdn_val=\"%s\"\n", - new_rdn[ 0 ][ 0 ]->la_attr.bv_val, - new_rdn[ 0 ][ 0 ]->la_value.bv_val, 0 ); + new_rdn[ 0 ]->la_attr.bv_val, + new_rdn[ 0 ]->la_value.bv_val, 0 ); #endif if ( op->oq_modrdn.rs_deleteoldrdn ) { diff --git a/servers/slapd/back-ldbm/passwd.c b/servers/slapd/back-ldbm/passwd.c index fa6d34d869..74191f19a9 100644 --- a/servers/slapd/back-ldbm/passwd.c +++ b/servers/slapd/back-ldbm/passwd.c @@ -92,7 +92,7 @@ ldbm_back_exop_passwd( goto done; } - rc = dnNormalize2( NULL, &dn, &ndn ); + rc = dnNormalize2( NULL, &dn, &ndn, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { rs->sr_text = "Invalid DN"; goto done; diff --git a/servers/slapd/back-ldbm/proto-back-ldbm.h b/servers/slapd/back-ldbm/proto-back-ldbm.h index 1057130810..8cab433783 100644 --- a/servers/slapd/back-ldbm/proto-back-ldbm.h +++ b/servers/slapd/back-ldbm/proto-back-ldbm.h @@ -100,7 +100,7 @@ BI_entry_get_rw ldbm_back_entry_get; * filterindex.c */ -ID_BLOCK * filter_candidates LDAP_P(( Backend *be, Filter *f )); +ID_BLOCK * filter_candidates LDAP_P(( Operation *op, Filter *f )); /* * id2children.c @@ -157,13 +157,13 @@ index_param LDAP_P(( extern int index_values LDAP_P(( - Backend *be, + Operation *op, AttributeDescription *desc, BerVarray vals, ID id, - int op )); + int opid )); -int index_entry LDAP_P(( Backend *be, int r, Entry *e )); +int index_entry LDAP_P(( Operation *op, int r, Entry *e )); #define index_entry_add(be,e) index_entry((be),SLAP_INDEX_ADD_OP,(e)) #define index_entry_del(be,e) index_entry((be),SLAP_INDEX_DELETE_OP,(e)) diff --git a/servers/slapd/back-ldbm/search.c b/servers/slapd/back-ldbm/search.c index dc51c35318..3c84a361dd 100644 --- a/servers/slapd/back-ldbm/search.c +++ b/servers/slapd/back-ldbm/search.c @@ -20,7 +20,7 @@ static ID_BLOCK *base_candidate( Backend *be, Entry *e ); static ID_BLOCK *search_candidates( - Backend *be, Entry *e, Filter *filter, + Operation *op, Entry *e, Filter *filter, int scope, int deref, int manageDSAit ); @@ -84,7 +84,7 @@ ldbm_back_search( } #endif /* LDAP_CACHING */ - candidates = search_candidates( op->o_bd, e, op->oq_search.rs_filter, + candidates = search_candidates( op, e, op->oq_search.rs_filter, op->oq_search.rs_scope, op->oq_search.rs_deref, manageDSAit || get_domainScope(op) ); @@ -194,7 +194,7 @@ ldbm_back_search( } else { cscope = ( op->oq_search.rs_scope != LDAP_SCOPE_SUBTREE ) ? LDAP_SCOPE_BASE : LDAP_SCOPE_SUBTREE; - candidates = search_candidates( op->o_bd, e, op->oq_search.rs_filter, + candidates = search_candidates( op, e, op->oq_search.rs_filter, op->oq_search.rs_scope, op->oq_search.rs_deref, manageDSAit ); } @@ -606,7 +606,7 @@ base_candidate( static ID_BLOCK * search_candidates( - Backend *be, + Operation *op, Entry *e, Filter *filter, int scope, @@ -663,7 +663,7 @@ search_candidates( fand.f_dn = &e->e_nname; fand.f_next = xf.f_or == filter ? filter : &xf ; - candidates = filter_candidates( be, &f ); + candidates = filter_candidates( op, &f ); return( candidates ); } diff --git a/servers/slapd/back-ldbm/tools.c b/servers/slapd/back-ldbm/tools.c index 3b253abee6..64d930a610 100644 --- a/servers/slapd/back-ldbm/tools.c +++ b/servers/slapd/back-ldbm/tools.c @@ -173,6 +173,7 @@ ID ldbm_tool_entry_put( Datum key, data; int rc, len; ID id; + Operation op = {0}; assert( slapMode & SLAP_TOOL_MODE ); assert( id2entry != NULL ); @@ -216,7 +217,11 @@ ID ldbm_tool_entry_put( return NOID; } - rc = index_entry_add( be, e ); + op.o_bd = be; + op.o_tmpmemctx = NULL; + op.o_tmpmfuncs = &ch_mfuncs; + + rc = index_entry_add( &op, e ); if( rc != 0 ) { strncpy( text->bv_val, "index add failed", text->bv_len ); return NOID; @@ -260,6 +265,7 @@ int ldbm_tool_entry_reindex( { int rc; Entry *e; + Operation op = {0}; #ifdef NEW_LOGGING LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_tool_entry_reindex: ID=%ld\n", @@ -302,7 +308,11 @@ int ldbm_tool_entry_reindex( #endif dn2id_add( be, &e->e_nname, e->e_id ); - rc = index_entry_add( be, e ); + + op.o_bd = be; + op.o_tmpmemctx = NULL; + op.o_tmpmfuncs = &ch_mfuncs; + rc = index_entry_add( &op, e ); entry_free( e ); diff --git a/servers/slapd/back-monitor/conn.c b/servers/slapd/back-monitor/conn.c index 8b8287f201..538396434e 100644 --- a/servers/slapd/back-monitor/conn.c +++ b/servers/slapd/back-monitor/conn.c @@ -394,7 +394,7 @@ monitor_subsys_conn_create( *ep = e; } else { - LDAPRDN *values = NULL; + LDAPRDN values = NULL; const char *text = NULL; unsigned long connid; @@ -407,9 +407,9 @@ monitor_subsys_conn_create( } assert( values ); - assert( values[ 0 ][ 0 ] ); + assert( values[ 0 ] ); - connid = atol( values[ 0 ][ 0 ]->la_value.bv_val + connid = atol( values[ 0 ]->la_value.bv_val + sizeof( CONN_CN_PREFIX ) ); ldap_rdnfree( values ); diff --git a/servers/slapd/back-passwd/search.c b/servers/slapd/back-passwd/search.c index a6f2c9e49b..52d8ae81bf 100644 --- a/servers/slapd/back-passwd/search.c +++ b/servers/slapd/back-passwd/search.c @@ -33,7 +33,7 @@ passwd_back_search( char *s; time_t stoptime; - LDAPRDN *rdn = NULL; + LDAPRDN rdn = NULL; struct berval parent = { 0, NULL }; AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass; @@ -74,13 +74,13 @@ passwd_back_search( goto done; } - if( slap_bv2ad( &rdn[0][0]->la_attr, &desc, &rs->sr_text )) { + if( slap_bv2ad( &rdn[0]->la_attr, &desc, &rs->sr_text )) { rs->sr_err = LDAP_NO_SUCH_OBJECT; ldap_rdnfree(rdn); goto done; } - vals[0] = rdn[0][0]->la_value; + vals[0] = rdn[0]->la_value; attr_mergeit( e, desc, vals ); ldap_rdnfree(rdn); @@ -185,7 +185,7 @@ passwd_back_search( ldap_pvt_thread_mutex_lock( &passwd_mutex ); pw_start( op->o_bd ); - if ( (pw = getpwnam( rdn[0][0]->la_value.bv_val )) == NULL ) { + if ( (pw = getpwnam( rdn[0]->la_value.bv_val )) == NULL ) { rs->sr_matched = parent.bv_val; rs->sr_err = LDAP_NO_SUCH_OBJECT; ldap_pvt_thread_mutex_unlock( &passwd_mutex ); diff --git a/servers/slapd/back-sql/modify.c b/servers/slapd/back-sql/modify.c index 10bcd29f71..8b1a376673 100644 --- a/servers/slapd/back-sql/modify.c +++ b/servers/slapd/back-sql/modify.c @@ -555,8 +555,8 @@ backsql_modrdn( Operation *op, SlapReply *rs ) struct berval p_dn, p_ndn, *new_pdn = NULL, *new_npdn = NULL, new_dn, new_ndn; - LDAPRDN *new_rdn = NULL; - LDAPRDN *old_rdn = NULL; + LDAPRDN new_rdn = NULL; + LDAPRDN old_rdn = NULL; Entry e; Modifications *mod; struct berval *newSuperior = op->oq_modrdn.rs_newSup; @@ -785,14 +785,14 @@ backsql_modrdn( Operation *op, SlapReply *rs ) LDAP_LOG ( OPERATION, RESULTS, "backsql_modrdn: new_rdn_type=\"%s\", " "new_rdn_val=\"%s\"\n", - new_rdn[ 0 ][ 0 ]->la_attr.bv_val, - new_rdn[ 0 ][ 0 ]->la_value.bv_val, 0 ); + new_rdn[ 0 ]->la_attr.bv_val, + new_rdn[ 0 ]->la_value.bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "backsql_modrdn: new_rdn_type=\"%s\", " "new_rdn_val=\"%s\"\n", - new_rdn[ 0 ][ 0 ]->la_attr.bv_val, - new_rdn[ 0 ][ 0 ]->la_value.bv_val, 0 ); + new_rdn[ 0 ]->la_attr.bv_val, + new_rdn[ 0 ]->la_value.bv_val, 0 ); #endif if ( op->oq_modrdn.rs_deleteoldrdn ) { diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 536941a16b..f1c319d6bb 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -1143,7 +1143,7 @@ backend_group( rc = value_find_ex( group_at, SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, - a->a_nvals, op_ndn ); + a->a_nvals, op_ndn, op->o_tmpmemctx ); } else { rc = LDAP_NO_SUCH_ATTRIBUTE; } diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index 0eea2b823f..1c6c29612e 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -161,7 +161,7 @@ do_bind( goto cleanup; } - rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn ); + rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx ); if ( rs->sr_err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, INFO, @@ -543,7 +543,7 @@ do_bind( if ( rs->sr_err != SLAPI_BIND_ANONYMOUS ) { slapi_pblock_get( pb, SLAPI_CONN_DN, (void *)&op->orb_edn.bv_val ); } - rs->sr_err = dnPrettyNormal( NULL, &op->orb_edn, &op->o_req_dn, &op->o_req_ndn ); + rs->sr_err = dnPrettyNormal( NULL, &op->orb_edn, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx ); ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex ); op->o_conn->c_dn = op->o_req_dn; op->o_conn->c_ndn = op->o_req_ndn; @@ -588,14 +588,10 @@ do_bind( if(op->orb_edn.bv_len) { op->o_conn->c_dn = op->orb_edn; } else { - op->o_conn->c_dn = op->o_req_dn; - op->o_req_dn.bv_val = NULL; - op->o_req_dn.bv_len = 0; + ber_dupbv(&op->o_conn->c_dn, &op->o_req_dn); } - op->o_conn->c_ndn = op->o_req_ndn; - op->o_req_ndn.bv_val = NULL; - op->o_req_ndn.bv_len = 0; + ber_dupbv( &op->o_conn->c_ndn, &op->o_req_ndn ); if( op->o_conn->c_dn.bv_len != 0 ) { ber_len_t max = sockbuf_max_incoming_auth; @@ -649,11 +645,11 @@ cleanup: op->o_conn->c_sasl_bindop = NULL; if( op->o_req_dn.bv_val != NULL ) { - free( op->o_req_dn.bv_val ); + sl_free( op->o_req_dn.bv_val, op->o_tmpmemctx ); op->o_req_dn.bv_val = NULL; } if( op->o_req_ndn.bv_val != NULL ) { - free( op->o_req_ndn.bv_val ); + sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx ); op->o_req_ndn.bv_val = NULL; } diff --git a/servers/slapd/compare.c b/servers/slapd/compare.c index 415592186c..92d0a45350 100644 --- a/servers/slapd/compare.c +++ b/servers/slapd/compare.c @@ -110,7 +110,7 @@ do_compare( goto cleanup; } - rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn ); + rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx ); if( rs->sr_err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, INFO, @@ -133,7 +133,7 @@ do_compare( rs->sr_err = asserted_value_validate_normalize( ava.aa_desc, ava.aa_desc->ad_type->sat_equality, SLAP_MR_EQUALITY|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX, - &value, &ava.aa_value, &rs->sr_text ); + &value, &ava.aa_value, &rs->sr_text, op->o_tmpmemctx ); if( rs->sr_err != LDAP_SUCCESS ) { send_ldap_result( op, rs ); goto cleanup; @@ -330,7 +330,7 @@ static int compare_entry( SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH | SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH, a->a_nvals, - &ava->aa_value ) == 0 ) + &ava->aa_value, op->o_tmpmemctx ) == 0 ) { rc = LDAP_COMPARE_TRUE; break; diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 8951f40664..5adaada4c4 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -481,7 +481,7 @@ read_config( const char *fname, int depth ) rc = dnPrettyNormal( NULL, &dn, &default_search_base, - &default_search_nbase ); + &default_search_nbase, NULL ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING @@ -659,10 +659,10 @@ read_config( const char *fname, int depth ) ber_str2bv( cargv[1], 0, 0, &dn ); if ( be ) { rc = dnPrettyNormal( NULL, &dn, &be->be_schemadn, - &be->be_schemandn ); + &be->be_schemandn, NULL ); } else { rc = dnPrettyNormal( NULL, &dn, &global_schemadn, - &global_schemandn ); + &global_schemandn, NULL ); } if ( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING @@ -973,7 +973,7 @@ read_config( const char *fname, int depth ) dn.bv_val = cargv[1]; dn.bv_len = strlen( cargv[1] ); - rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn ); + rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, NULL ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG( CONFIG, CRIT, @@ -1117,7 +1117,7 @@ read_config( const char *fname, int depth ) rc = dnPrettyNormal( NULL, &dn, &be->be_rootdn, - &be->be_rootndn ); + &be->be_rootndn, NULL ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING @@ -1879,7 +1879,7 @@ read_config( const char *fname, int depth ) dn.bv_val = cargv[1]; dn.bv_len = strlen( cargv[1] ); - rc = dnNormalize2( NULL, &dn, &be->be_update_ndn ); + rc = dnNormalize2( NULL, &dn, &be->be_update_ndn, NULL ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG( CONFIG, CRIT, @@ -2416,7 +2416,7 @@ read_config( const char *fname, int depth ) if ( !global_schemadn.bv_val ) { ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1, &global_schemadn ); - dnNormalize2( NULL, &global_schemadn, &global_schemandn ); + dnNormalize2( NULL, &global_schemadn, &global_schemandn, NULL ); } if ( load_ucdata( NULL ) < 0 ) return 1; diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 09410a3f27..67ec8daea8 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -919,7 +919,7 @@ connection_operation( void *ctx, void *arg_v ) memsiz = ber_len( op->o_ber ) * 32; if ( SLAB_SIZE > memsiz ) memsiz = SLAB_SIZE; - if ( tag == LDAP_REQ_SEARCH ) { + if ( tag != LDAP_REQ_ADD ) { memctx = sl_mem_create( memsiz, ctx ); ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, memctx ); op->o_tmpmemctx = memctx; diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index daade821c0..64b32f8dbe 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -76,7 +76,7 @@ do_delete( goto cleanup; } - rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn ); + rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx ); if( rs->sr_err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, INFO, diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 0df75dfadb..b02680096c 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -42,21 +42,21 @@ * structural representation of a distinguished name. */ static int -LDAPDN_validate( LDAPDN *dn ) +LDAPDN_validate( LDAPDN dn ) { int iRDN; int rc; assert( dn ); - for ( iRDN = 0; dn[ 0 ][ iRDN ]; iRDN++ ) { - LDAPRDN *rdn = dn[ 0 ][ iRDN ]; + for ( iRDN = 0; dn[ iRDN ]; iRDN++ ) { + LDAPRDN rdn = dn[ iRDN ]; int iAVA; assert( rdn ); - for ( iAVA = 0; rdn[ 0 ][ iAVA ]; iAVA++ ) { - LDAPAVA *ava = rdn[ 0 ][ iAVA ]; + for ( iAVA = 0; rdn[ iAVA ]; iAVA++ ) { + LDAPAVA *ava = rdn[ iAVA ]; AttributeDescription *ad; slap_syntax_validate_func *validate = NULL; @@ -106,7 +106,7 @@ dnValidate( struct berval *in ) { int rc; - LDAPDN *dn = NULL; + LDAPDN dn = NULL; assert( in ); @@ -152,16 +152,16 @@ dnValidate( * a RDN should be limited. */ static void -AVA_Sort( LDAPRDN *rdn, int iAVA ) +AVA_Sort( LDAPRDN rdn, int iAVA ) { int i; - LDAPAVA *ava_in = rdn[ 0 ][ iAVA ]; + LDAPAVA *ava_in = rdn[ iAVA ]; assert( rdn ); assert( ava_in ); for ( i = 0; i < iAVA; i++ ) { - LDAPAVA *ava = rdn[ 0 ][ i ]; + LDAPAVA *ava = rdn[ i ]; int a, j; assert( ava ); @@ -200,7 +200,7 @@ AVA_Sort( LDAPRDN *rdn, int iAVA ) return; } - ava = rdn[ 0 ][ i ]; + ava = rdn[ i ]; a = strcmp( ava_in->la_attr.bv_val, ava->la_attr.bv_val ); } @@ -209,9 +209,9 @@ AVA_Sort( LDAPRDN *rdn, int iAVA ) * move ahead */ for ( j = iAVA; j > i; j-- ) { - rdn[ 0 ][ j ] = rdn[ 0 ][ j - 1 ]; + rdn[ j ] = rdn[ j - 1 ]; } - rdn[ 0 ][ i ] = ava_in; + rdn[ i ] = ava_in; return; } @@ -222,21 +222,21 @@ AVA_Sort( LDAPRDN *rdn, int iAVA ) * structural representation of a distinguished name. */ static int -LDAPDN_rewrite( LDAPDN *dn, unsigned flags ) +LDAPDN_rewrite( LDAPDN dn, unsigned flags, void *ctx ) { int iRDN; int rc; assert( dn ); - for ( iRDN = 0; dn[ 0 ][ iRDN ]; iRDN++ ) { - LDAPRDN *rdn = dn[ 0 ][ iRDN ]; + for ( iRDN = 0; dn[ iRDN ]; iRDN++ ) { + LDAPRDN rdn = dn[ iRDN ]; int iAVA; assert( rdn ); - for ( iAVA = 0; rdn[ 0 ][ iAVA ]; iAVA++ ) { - LDAPAVA *ava = rdn[ 0 ][ iAVA ]; + for ( iAVA = 0; rdn[ iAVA ]; iAVA++ ) { + LDAPAVA *ava = rdn[ iAVA ]; AttributeDescription *ad; slap_syntax_validate_func *validf = NULL; slap_mr_normalize_func *normf = NULL; @@ -303,7 +303,7 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags ) ava->la_value.bv_len ? &ava->la_value : (struct berval *) &slap_empty_bv, - &bv ); + &bv, ctx ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; @@ -322,7 +322,7 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags ) ava->la_value.bv_len ? &ava->la_value : (struct berval *) &slap_empty_bv, - &bv ); + &bv, ctx ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; @@ -331,7 +331,7 @@ LDAPDN_rewrite( LDAPDN *dn, unsigned flags ) if( bv.bv_val ) { - free( ava->la_value.bv_val ); + ber_memfree_x( ava->la_value.bv_val, ctx ); ava->la_value = bv; } @@ -348,7 +348,8 @@ dnNormalize( Syntax *syntax, MatchingRule *mr, struct berval *val, - struct berval *out ) + struct berval *out, + void *ctx) { assert( val ); assert( out ); @@ -356,13 +357,13 @@ dnNormalize( Debug( LDAP_DEBUG_TRACE, ">>> dnNormalize: <%s>\n", val->bv_val, 0, 0 ); if ( val->bv_len != 0 ) { - LDAPDN *dn = NULL; + LDAPDN dn = NULL; int rc; /* * Go to structural representation */ - rc = ldap_bv2dn( val, &dn, LDAP_DN_FORMAT_LDAP ); + rc = ldap_bv2dn_x( val, &dn, LDAP_DN_FORMAT_LDAP, ctx ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; } @@ -372,7 +373,7 @@ dnNormalize( /* * Schema-aware rewrite */ - if ( LDAPDN_rewrite( dn, 0 ) != LDAP_SUCCESS ) { + if ( LDAPDN_rewrite( dn, 0, ctx ) != LDAP_SUCCESS ) { ldap_dnfree( dn ); return LDAP_INVALID_SYNTAX; } @@ -380,16 +381,16 @@ dnNormalize( /* * Back to string representation */ - rc = ldap_dn2bv( dn, out, - LDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PRETTY ); + rc = ldap_dn2bv_x( dn, out, + LDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PRETTY, ctx ); - ldap_dnfree( dn ); + ldap_dnfree_x( dn, ctx ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; } } else { - ber_dupbv( out, val ); + ber_dupbv_x( out, val, ctx ); } Debug( LDAP_DEBUG_TRACE, "<<< dnNormalize: <%s>\n", out->bv_val, 0, 0 ); @@ -426,7 +427,8 @@ int dnPretty2( Syntax *syntax, struct berval *val, - struct berval *out) + struct berval *out, + void *ctx) { assert( val ); assert( out ); @@ -438,17 +440,17 @@ dnPretty2( #endif if ( val->bv_len == 0 ) { - ber_dupbv( out, val ); + ber_dupbv_x( out, val, ctx ); } else if ( val->bv_len > SLAP_LDAPDN_MAXLEN ) { return LDAP_INVALID_SYNTAX; } else { - LDAPDN *dn = NULL; + LDAPDN dn = NULL; int rc; /* FIXME: should be liberal in what we accept */ - rc = ldap_bv2dn( val, &dn, LDAP_DN_FORMAT_LDAP ); + rc = ldap_bv2dn_x( val, &dn, LDAP_DN_FORMAT_LDAP, ctx ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; } @@ -458,8 +460,8 @@ dnPretty2( /* * Schema-aware rewrite */ - if ( LDAPDN_rewrite( dn, SLAP_LDAPDN_PRETTY ) != LDAP_SUCCESS ) { - ldap_dnfree( dn ); + if ( LDAPDN_rewrite( dn, SLAP_LDAPDN_PRETTY, ctx ) != LDAP_SUCCESS ) { + ldap_dnfree_x( dn, ctx ); return LDAP_INVALID_SYNTAX; } @@ -467,10 +469,10 @@ dnPretty2( /* RE: the default is the form that is used as * an internal representation; the pretty form * is a variant */ - rc = ldap_dn2bv( dn, out, - LDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PRETTY ); + rc = ldap_dn2bv_x( dn, out, + LDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PRETTY, ctx ); - ldap_dnfree( dn ); + ldap_dnfree_x( dn, ctx ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; @@ -486,8 +488,9 @@ int dnPrettyNormalDN( Syntax *syntax, struct berval *val, - LDAPDN **dn, - int flags ) + LDAPDN *dn, + int flags, + void *ctx ) { assert( val ); assert( dn ); @@ -512,7 +515,7 @@ dnPrettyNormalDN( int rc; /* FIXME: should be liberal in what we accept */ - rc = ldap_bv2dn( val, dn, LDAP_DN_FORMAT_LDAP ); + rc = ldap_bv2dn_x( val, dn, LDAP_DN_FORMAT_LDAP, ctx ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; } @@ -522,8 +525,8 @@ dnPrettyNormalDN( /* * Schema-aware rewrite */ - if ( LDAPDN_rewrite( *dn, flags ) != LDAP_SUCCESS ) { - ldap_dnfree( *dn ); + if ( LDAPDN_rewrite( *dn, flags, ctx ) != LDAP_SUCCESS ) { + ldap_dnfree_x( *dn, ctx ); *dn = NULL; return LDAP_INVALID_SYNTAX; } @@ -544,7 +547,8 @@ dnPrettyNormal( Syntax *syntax, struct berval *val, struct berval *pretty, - struct berval *normal) + struct berval *normal, + void *ctx) { #ifdef NEW_LOGGING LDAP_LOG ( OPERATION, ENTRY, ">>> dnPrettyNormal: <%s>\n", val->bv_val, 0, 0 ); @@ -557,15 +561,15 @@ dnPrettyNormal( assert( normal ); if ( val->bv_len == 0 ) { - ber_dupbv( pretty, val ); - ber_dupbv( normal, val ); + ber_dupbv_x( pretty, val, ctx ); + ber_dupbv_x( normal, val, ctx ); } else if ( val->bv_len > SLAP_LDAPDN_MAXLEN ) { /* too big */ return LDAP_INVALID_SYNTAX; } else { - LDAPDN *dn = NULL; + LDAPDN dn = NULL; int rc; pretty->bv_val = NULL; @@ -574,7 +578,7 @@ dnPrettyNormal( normal->bv_len = 0; /* FIXME: should be liberal in what we accept */ - rc = ldap_bv2dn( val, &dn, LDAP_DN_FORMAT_LDAP ); + rc = ldap_bv2dn_x( val, &dn, LDAP_DN_FORMAT_LDAP, ctx ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; } @@ -584,33 +588,33 @@ dnPrettyNormal( /* * Schema-aware rewrite */ - if ( LDAPDN_rewrite( dn, SLAP_LDAPDN_PRETTY ) != LDAP_SUCCESS ) { - ldap_dnfree( dn ); + if ( LDAPDN_rewrite( dn, SLAP_LDAPDN_PRETTY, ctx ) != LDAP_SUCCESS ) { + ldap_dnfree_x( dn, ctx ); return LDAP_INVALID_SYNTAX; } - rc = ldap_dn2bv( dn, pretty, - LDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PRETTY ); + rc = ldap_dn2bv_x( dn, pretty, + LDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PRETTY, ctx ); if ( rc != LDAP_SUCCESS ) { - ldap_dnfree( dn ); + ldap_dnfree_x( dn, ctx ); return LDAP_INVALID_SYNTAX; } - if ( LDAPDN_rewrite( dn, 0 ) != LDAP_SUCCESS ) { - ldap_dnfree( dn ); - free( pretty->bv_val ); + if ( LDAPDN_rewrite( dn, 0, ctx ) != LDAP_SUCCESS ) { + ldap_dnfree_x( dn, ctx ); + ber_memfree_x( pretty->bv_val, ctx ); pretty->bv_val = NULL; pretty->bv_len = 0; return LDAP_INVALID_SYNTAX; } - rc = ldap_dn2bv( dn, normal, - LDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PRETTY ); + rc = ldap_dn2bv_x( dn, normal, + LDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PRETTY, ctx ); - ldap_dnfree( dn ); + ldap_dnfree_x( dn, ctx ); if ( rc != LDAP_SUCCESS ) { - free( pretty->bv_val ); + ber_memfree_x( pretty->bv_val, ctx ); pretty->bv_val = NULL; pretty->bv_len = 0; return LDAP_INVALID_SYNTAX; @@ -701,9 +705,10 @@ dnParent( int dnExtractRdn( struct berval *dn, - struct berval *rdn ) + struct berval *rdn, + void *ctx ) { - LDAPRDN *tmpRDN; + LDAPRDN tmpRDN; const char *p; int rc; @@ -714,14 +719,14 @@ dnExtractRdn( return LDAP_OTHER; } - rc = ldap_bv2rdn( dn, &tmpRDN, (char **)&p, LDAP_DN_FORMAT_LDAP ); + rc = ldap_bv2rdn_x( dn, &tmpRDN, (char **)&p, LDAP_DN_FORMAT_LDAP, ctx ); if ( rc != LDAP_SUCCESS ) { return rc; } - rc = ldap_rdn2bv( tmpRDN, rdn, LDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PRETTY ); + rc = ldap_rdn2bv_x( tmpRDN, rdn, LDAP_DN_FORMAT_LDAPV3 | LDAP_DN_PRETTY, ctx ); - ldap_rdnfree( tmpRDN ); + ldap_rdnfree_x( tmpRDN, ctx ); if ( rc != LDAP_SUCCESS ) { return rc; } diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index d01e525928..61749ad06b 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -127,7 +127,7 @@ str2entry( char *s ) return NULL; } - rc = dnPrettyNormal( NULL, &vals[0], &e->e_name, &e->e_nname ); + rc = dnPrettyNormal( NULL, &vals[0], &e->e_name, &e->e_nname, NULL ); if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, DETAIL1, @@ -191,7 +191,7 @@ str2entry( char *s ) if( pretty ) { rc = pretty( ad->ad_type->sat_syntax, - &vals[0], &pval ); + &vals[0], &pval, NULL ); } else if( validate ) { /* @@ -247,7 +247,7 @@ str2entry( char *s ) SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX, ad->ad_type->sat_syntax, ad->ad_type->sat_equality, - &vals[0], &nvals[0] ); + &vals[0], &nvals[0], NULL ); if( rc ) { #ifdef NEW_LOGGING @@ -442,6 +442,9 @@ entry_id_cmp( const void *v_e1, const void *v_e2 ) return( e1->e_id < e2->e_id ? -1 : (e1->e_id > e2->e_id ? 1 : 0) ); } +#define entry_lenlen(l) ((l) < 0x80) ? 1 : ((l) < 0x100) ? 2 : \ + ((l) < 0x10000) ? 3 : ((l) < 0x1000000) ? 4 : 5 +#if 0 /* This is like a ber_len */ static ber_len_t entry_lenlen(ber_len_t len) @@ -456,6 +459,7 @@ entry_lenlen(ber_len_t len) return 4; return 5; } +#endif static void entry_putlen(unsigned char **buf, ber_len_t len) diff --git a/servers/slapd/filter.c b/servers/slapd/filter.c index 9312bb97e8..19acd9e38d 100644 --- a/servers/slapd/filter.c +++ b/servers/slapd/filter.c @@ -426,7 +426,7 @@ get_ssa( /* validate/normalize using equality matching rule validator! */ rc = asserted_value_validate_normalize( ssa.sa_desc, ssa.sa_desc->ad_type->sat_equality, - usage, &value, &nvalue, text ); + usage, &value, &nvalue, text, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { goto return_error; @@ -448,7 +448,7 @@ get_ssa( || ssa.sa_any != NULL || ssa.sa_final.bv_val != NULL ) { - free( nvalue.bv_val ); + sl_free( nvalue.bv_val, op->o_tmpmemctx ); goto return_error; } @@ -465,15 +465,11 @@ get_ssa( #endif if ( ssa.sa_final.bv_val != NULL ) { - free( nvalue.bv_val ); + sl_free( nvalue.bv_val, op->o_tmpmemctx ); goto return_error; } -#ifdef notyet ber_bvarray_add_x( &ssa.sa_any, &nvalue, op->o_tmpmemctx ); -#else - ber_bvarray_add( &ssa.sa_any, &nvalue ); -#endif break; case LDAP_SUBSTRING_FINAL: @@ -486,7 +482,7 @@ get_ssa( #endif if ( ssa.sa_final.bv_val != NULL ) { - free( nvalue.bv_val ); + sl_free( nvalue.bv_val, op->o_tmpmemctx ); goto return_error; } @@ -505,7 +501,7 @@ get_ssa( #endif assert( 0 ); - free( nvalue.bv_val ); + sl_free( nvalue.bv_val, op->o_tmpmemctx ); return_error: #ifdef NEW_LOGGING @@ -516,9 +512,9 @@ return_error: Debug( LDAP_DEBUG_FILTER, " error=%ld\n", (long) rc, 0, 0 ); #endif - free( ssa.sa_initial.bv_val ); - ber_bvarray_free( ssa.sa_any ); - free( ssa.sa_final.bv_val ); + sl_free( ssa.sa_initial.bv_val, op->o_tmpmemctx ); + ber_bvarray_free_x( ssa.sa_any, op->o_tmpmemctx ); + sl_free( ssa.sa_final.bv_val, op->o_tmpmemctx ); return rc; } @@ -562,19 +558,11 @@ filter_free_x( Operation *op, Filter *f ) case LDAP_FILTER_SUBSTRINGS: if ( f->f_sub_initial.bv_val != NULL ) { -#ifdef notyet op->o_tmpfree( f->f_sub_initial.bv_val, op->o_tmpmemctx ); -#else - ch_free( f->f_sub_initial.bv_val ); -#endif } - ber_bvarray_free( f->f_sub_any ); + ber_bvarray_free_x( f->f_sub_any, op->o_tmpmemctx ); if ( f->f_sub_final.bv_val != NULL ) { -#ifdef notyet op->o_tmpfree( f->f_sub_final.bv_val, op->o_tmpmemctx ); -#else - ch_free( f->f_sub_final.bv_val ); -#endif } op->o_tmpfree( f->f_sub, op->o_tmpmemctx ); break; @@ -1150,19 +1138,11 @@ vrFilter_free( Operation *op, ValuesReturnFilter *vrf ) case LDAP_FILTER_SUBSTRINGS: if ( vrf->vrf_sub_initial.bv_val != NULL ) { -#ifdef notyet op->o_tmpfree( vrf->vrf_sub_initial.bv_val, op->o_tmpmemctx ); -#else - ch_free( vrf->vrf_sub_initial.bv_val ); -#endif } ber_bvarray_free_x( vrf->vrf_sub_any, op->o_tmpmemctx ); if ( vrf->vrf_sub_final.bv_val != NULL ) { -#ifdef notyet op->o_tmpfree( vrf->vrf_sub_final.bv_val, op->o_tmpmemctx ); -#else - ch_free( vrf->vrf_sub_final.bv_val ); -#endif } op->o_tmpfree( vrf->vrf_sub, op->o_tmpmemctx ); break; diff --git a/servers/slapd/filterentry.c b/servers/slapd/filterentry.c index 13cae45d14..386ea48a15 100644 --- a/servers/slapd/filterentry.c +++ b/servers/slapd/filterentry.c @@ -257,7 +257,7 @@ static int test_mra_filter( /* normalize for equality */ rc = asserted_value_validate_normalize( a->a_desc, mra->ma_rule, SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX, - &mra->ma_value, &value, &text ); + &mra->ma_value, &value, &text, op->o_tmpmemctx ); if ( rc != LDAP_SUCCESS ) { continue; } @@ -294,22 +294,22 @@ static int test_mra_filter( /* check attrs in DN AVAs if required */ if ( mra->ma_dnattrs ) { - LDAPDN *dn = NULL; + LDAPDN dn = NULL; int iRDN, iAVA; int rc; /* parse and pretty the dn */ - rc = dnPrettyDN( NULL, &e->e_name, &dn ); + rc = dnPrettyDN( NULL, &e->e_name, &dn, op->o_tmpmemctx ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; } /* for each AVA of each RDN ... */ - for ( iRDN = 0; dn[ 0 ][ iRDN ]; iRDN++ ) { - LDAPRDN *rdn = dn[ 0 ][ iRDN ]; + for ( iRDN = 0; dn[ iRDN ]; iRDN++ ) { + LDAPRDN rdn = dn[ iRDN ]; - for ( iAVA = 0; rdn[ 0 ][ iAVA ]; iAVA++ ) { - LDAPAVA *ava = rdn[ 0 ][ iAVA ]; + for ( iAVA = 0; rdn[ iAVA ]; iAVA++ ) { + LDAPAVA *ava = rdn[ iAVA ]; struct berval *bv = &ava->la_value, value; AttributeDescription *ad = (AttributeDescription *)ava->la_private; int ret; @@ -337,7 +337,7 @@ static int test_mra_filter( rc = asserted_value_validate_normalize( ad, mra->ma_rule, SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX, - &mra->ma_value, &value, &text ); + &mra->ma_value, &value, &text, op->o_tmpmemctx ); if ( rc != LDAP_SUCCESS ) { continue; } @@ -354,12 +354,12 @@ static int test_mra_filter( bv, &value, &text ); if( rc != LDAP_SUCCESS ) { - ldap_dnfree( dn ); + ldap_dnfree_x( dn, op->o_tmpmemctx ); return rc; } if ( ret == 0 ) { - ldap_dnfree( dn ); + ldap_dnfree_x( dn, op->o_tmpmemctx ); return LDAP_COMPARE_TRUE; } } diff --git a/servers/slapd/limits.c b/servers/slapd/limits.c index 7fae9b282f..5a32b6508b 100644 --- a/servers/slapd/limits.c +++ b/servers/slapd/limits.c @@ -174,7 +174,7 @@ add_limits( bv.bv_val = (char *) pattern; bv.bv_len = strlen( pattern ); - rc = dnNormalize2( NULL, &bv, &lm->lm_dn_pat ); + rc = dnNormalize2( NULL, &bv, &lm->lm_dn_pat, NULL ); if ( rc != LDAP_SUCCESS ) { ch_free( lm ); return( -1 ); diff --git a/servers/slapd/matchedValues.c b/servers/slapd/matchedValues.c index e13d661296..39cb6426bb 100644 --- a/servers/slapd/matchedValues.c +++ b/servers/slapd/matchedValues.c @@ -357,7 +357,7 @@ test_mra_vrFilter( rc = asserted_value_validate_normalize( a->a_desc, mra->ma_rule, SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX, - &mra->ma_value, &value, &text ); + &mra->ma_value, &value, &text, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) continue; } diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 8944b2297f..c00bb762d5 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -177,7 +177,7 @@ do_modify( goto cleanup; } - rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn ); + rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx ); if( rs->sr_err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, INFO, "do_modify: conn %d invalid dn (%s)\n", @@ -394,7 +394,7 @@ do_modify( size_t textlen = sizeof textbuf; rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text, - textbuf, textlen ); + textbuf, textlen, op->o_tmpmemctx ); if( rs->sr_err != LDAP_SUCCESS ) { send_ldap_result( op, rs ); @@ -476,7 +476,8 @@ int slap_mods_check( int update, const char **text, char *textbuf, - size_t textlen ) + size_t textlen, + void *ctx ) { int rc; @@ -577,7 +578,7 @@ int slap_mods_check( struct berval pval; if( pretty ) { rc = pretty( ad->ad_type->sat_syntax, - &ml->sml_values[nvals], &pval ); + &ml->sml_values[nvals], &pval, ctx ); } else { rc = validate( ad->ad_type->sat_syntax, &ml->sml_values[nvals] ); @@ -592,7 +593,7 @@ int slap_mods_check( } if( pretty ) { - ber_memfree( ml->sml_values[nvals].bv_val ); + ber_memfree_x( ml->sml_values[nvals].bv_val, ctx ); ml->sml_values[nvals] = pval; } } @@ -614,13 +615,13 @@ int slap_mods_check( if( nvals && ad->ad_type->sat_equality && ad->ad_type->sat_equality->smr_normalize ) { - ml->sml_nvalues = ch_malloc( (nvals+1)*sizeof(struct berval) ); + ml->sml_nvalues = ber_memalloc_x( (nvals+1)*sizeof(struct berval), ctx ); for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) { rc = ad->ad_type->sat_equality->smr_normalize( 0, ad->ad_type->sat_syntax, ad->ad_type->sat_equality, - &ml->sml_values[nvals], &ml->sml_nvalues[nvals] ); + &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx ); if( rc ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, DETAIL1, diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index 83ce08eeb8..49d6a3842a 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -173,7 +173,7 @@ do_modrdn( goto cleanup; } - rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn ); + rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx ); if( rs->sr_err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, INFO, @@ -216,7 +216,7 @@ do_modrdn( /* FIXME: should have/use rdnPretty / rdnNormalize routines */ - rs->sr_err = dnPrettyNormal( NULL, &newrdn, &op->orr_newrdn, &op->orr_nnewrdn ); + rs->sr_err = dnPrettyNormal( NULL, &newrdn, &op->orr_newrdn, &op->orr_nnewrdn, op->o_tmpmemctx ); if( rs->sr_err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, INFO, @@ -245,7 +245,7 @@ do_modrdn( if( op->orr_newSup ) { rs->sr_err = dnPrettyNormal( NULL, &newSuperior, &pnewSuperior, - &nnewSuperior ); + &nnewSuperior, op->o_tmpmemctx ); if( rs->sr_err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, INFO, @@ -407,8 +407,8 @@ slap_modrdn2mods( Operation *op, SlapReply *rs, Entry *e, - LDAPRDN *old_rdn, - LDAPRDN *new_rdn, + LDAPRDN old_rdn, + LDAPRDN new_rdn, Modifications **pmod ) { Modifications *mod = NULL; @@ -418,40 +418,40 @@ slap_modrdn2mods( assert( !op->orr_deleteoldrdn || old_rdn != NULL ); /* Add new attribute values to the entry */ - for ( a_cnt = 0; new_rdn[0][a_cnt]; a_cnt++ ) { + for ( a_cnt = 0; new_rdn[a_cnt]; a_cnt++ ) { AttributeDescription *desc = NULL; Modifications *mod_tmp; - rs->sr_err = slap_bv2ad( &new_rdn[0][a_cnt]->la_attr, &desc, &rs->sr_text ); + rs->sr_err = slap_bv2ad( &new_rdn[a_cnt]->la_attr, &desc, &rs->sr_text ); if ( rs->sr_err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG ( OPERATION, ERR, "slap_modrdn2modlist: %s: %s (new)\n", rs->sr_text, - new_rdn[ 0 ][ a_cnt ]->la_attr.bv_val, 0 ); + new_rdn[ a_cnt ]->la_attr.bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_modrdn2modlist: %s: %s (new)\n", rs->sr_text, - new_rdn[ 0 ][ a_cnt ]->la_attr.bv_val, 0 ); + new_rdn[ a_cnt ]->la_attr.bv_val, 0 ); #endif goto done; } /* ACL check of newly added attrs */ if ( op->o_bd && !access_allowed( op, e, desc, - &new_rdn[0][a_cnt]->la_value, ACL_WRITE, NULL ) ) { + &new_rdn[a_cnt]->la_value, ACL_WRITE, NULL ) ) { #ifdef NEW_LOGGING LDAP_LOG ( OPERATION, ERR, "slap_modrdn2modlist: access to attr \"%s\" " "(new) not allowed\n", - new_rdn[0][a_cnt]->la_attr.bv_val, 0, 0 ); + new_rdn[a_cnt]->la_attr.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_modrdn2modlist: access to attr \"%s\" " "(new) not allowed\n", - new_rdn[0][ a_cnt ]->la_attr.bv_val, 0, 0 ); + new_rdn[ a_cnt ]->la_attr.bv_val, 0, 0 ); #endif rs->sr_err = LDAP_INSUFFICIENT_ACCESS; goto done; @@ -462,7 +462,7 @@ slap_modrdn2mods( + 4 * sizeof( struct berval ) ); mod_tmp->sml_desc = desc; mod_tmp->sml_values = ( BerVarray )( mod_tmp + 1 ); - mod_tmp->sml_values[0] = new_rdn[0][a_cnt]->la_value; + mod_tmp->sml_values[0] = new_rdn[a_cnt]->la_value; mod_tmp->sml_values[1].bv_val = NULL; if( desc->ad_type->sat_equality->smr_normalize) { mod_tmp->sml_nvalues = &mod_tmp->sml_values[2]; @@ -471,7 +471,7 @@ slap_modrdn2mods( desc->ad_type->sat_syntax, desc->ad_type->sat_equality, &mod_tmp->sml_values[0], - &mod_tmp->sml_nvalues[0] ); + &mod_tmp->sml_nvalues[0], op->o_tmpmemctx ); mod_tmp->sml_nvalues[1].bv_val = NULL; } else { mod_tmp->sml_nvalues = NULL; @@ -483,23 +483,23 @@ slap_modrdn2mods( /* Remove old rdn value if required */ if ( op->orr_deleteoldrdn ) { - for ( d_cnt = 0; old_rdn[0][d_cnt]; d_cnt++ ) { + for ( d_cnt = 0; old_rdn[d_cnt]; d_cnt++ ) { AttributeDescription *desc = NULL; Modifications *mod_tmp; - rs->sr_err = slap_bv2ad( &old_rdn[0][d_cnt]->la_attr, &desc, &rs->sr_text ); + rs->sr_err = slap_bv2ad( &old_rdn[d_cnt]->la_attr, &desc, &rs->sr_text ); if ( rs->sr_err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG ( OPERATION, ERR, "slap_modrdn2modlist: %s: %s (old)\n", rs->sr_text, - old_rdn[0][d_cnt]->la_attr.bv_val, + old_rdn[d_cnt]->la_attr.bv_val, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_modrdn2modlist: %s: %s (old)\n", rs->sr_text, - old_rdn[0][d_cnt]->la_attr.bv_val, + old_rdn[d_cnt]->la_attr.bv_val, 0 ); #endif goto done; @@ -507,19 +507,19 @@ slap_modrdn2mods( /* ACL check of newly added attrs */ if ( op->o_bd && !access_allowed( op, e, desc, - &old_rdn[0][d_cnt]->la_value, ACL_WRITE, + &old_rdn[d_cnt]->la_value, ACL_WRITE, NULL ) ) { #ifdef NEW_LOGGING LDAP_LOG ( OPERATION, ERR, "slap_modrdn2modlist: access " "to attr \"%s\" (old) not allowed\n", - old_rdn[ 0 ][ d_cnt ]->la_attr.bv_val, + old_rdn[ d_cnt ]->la_attr.bv_val, 0, 0 ); #else Debug( LDAP_DEBUG_TRACE, "slap_modrdn2modlist: access " "to attr \"%s\" (old) not allowed\n", - old_rdn[ 0 ][ d_cnt ]->la_attr.bv_val, + old_rdn[ d_cnt ]->la_attr.bv_val, 0, 0 ); #endif rs->sr_err = LDAP_INSUFFICIENT_ACCESS; @@ -531,7 +531,7 @@ slap_modrdn2mods( + 4 * sizeof ( struct berval ) ); mod_tmp->sml_desc = desc; mod_tmp->sml_values = ( BerVarray )(mod_tmp+1); - mod_tmp->sml_values[0] = old_rdn[0][d_cnt]->la_value; + mod_tmp->sml_values[0] = old_rdn[d_cnt]->la_value; mod_tmp->sml_values[1].bv_val = NULL; if( desc->ad_type->sat_equality->smr_normalize) { mod_tmp->sml_nvalues = &mod_tmp->sml_values[2]; @@ -540,7 +540,7 @@ slap_modrdn2mods( desc->ad_type->sat_syntax, desc->ad_type->sat_equality, &mod_tmp->sml_values[0], - &mod_tmp->sml_nvalues[0] ); + &mod_tmp->sml_nvalues[0], op->o_tmpmemctx ); mod_tmp->sml_nvalues[1].bv_val = NULL; } else { mod_tmp->sml_nvalues = NULL; diff --git a/servers/slapd/mra.c b/servers/slapd/mra.c index 7e3a179030..ce4a86def0 100644 --- a/servers/slapd/mra.c +++ b/servers/slapd/mra.c @@ -212,7 +212,7 @@ get_mra( rc = asserted_value_validate_normalize( ma.ma_desc, ma.ma_rule, SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX, - &value, &ma.ma_value, text ); + &value, &ma.ma_value, text, op->o_tmpmemctx ); if( rc != LDAP_SUCCESS ) { return rc; diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 235d0a447e..0ea64da225 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -148,10 +148,10 @@ LDAP_SLAPD_F (int) attr_merge_one LDAP_P(( Entry *e, struct berval *nval )); LDAP_SLAPD_F (int) attr_merge_normalize LDAP_P(( Entry *e, AttributeDescription *desc, - BerVarray vals )); + BerVarray vals, void *memctx )); LDAP_SLAPD_F (int) attr_merge_normalize_one LDAP_P(( Entry *e, AttributeDescription *desc, - struct berval *val )); + struct berval *val, void *memctx )); LDAP_SLAPD_F (Attribute *) attrs_find LDAP_P(( Attribute *a, AttributeDescription *desc )); LDAP_SLAPD_F (Attribute *) attr_find LDAP_P(( @@ -370,29 +370,22 @@ LDAP_SLAPD_F (int) dnValidate LDAP_P(( Syntax *syntax, struct berval *val )); -LDAP_SLAPD_F (int) dnNormalize LDAP_P(( - slap_mask_t use, - Syntax *syntax, - MatchingRule *mr, - struct berval *val, - struct berval *normalized )); -#define dnNormalize2(s,v,n) dnNormalize(0,(s),NULL,(v),(n)) +LDAP_SLAPD_F (slap_mr_normalize_func) dnNormalize; +#define dnNormalize2(s,v,n,x) dnNormalize(0,(s),NULL,(v),(n),(x)) LDAP_SLAPD_F (int) dnPretty LDAP_P(( Syntax *syntax, struct berval *val, struct berval **pretty )); -LDAP_SLAPD_F (int) dnPretty2 LDAP_P(( - Syntax *syntax, - struct berval *val, - struct berval *pretty )); +LDAP_SLAPD_F (slap_syntax_transform_func) dnPretty2; LDAP_SLAPD_F (int) dnPrettyNormal LDAP_P(( Syntax *syntax, struct berval *val, struct berval *pretty, - struct berval *normal )); + struct berval *normal, + void *ctx )); LDAP_SLAPD_F (int) dnMatch LDAP_P(( int *matchp, @@ -406,7 +399,7 @@ LDAP_SLAPD_F (int) dnIsSuffix LDAP_P(( const struct berval *dn, const struct berval *suffix )); LDAP_SLAPD_F (int) dnExtractRdn LDAP_P(( - struct berval *dn, struct berval *rdn )); + struct berval *dn, struct berval *rdn, void *ctx )); LDAP_SLAPD_F (int) rdnValidate LDAP_P(( struct berval * rdn )); @@ -423,11 +416,11 @@ LDAP_SLAPD_F (int) dnX509normalize LDAP_P(( void *x509_name, struct berval *out LDAP_SLAPD_F (int) dnX509peerNormalize LDAP_P(( void *ssl, struct berval *dn )); -LDAP_SLAPD_F (int) dnPrettyNormalDN LDAP_P(( Syntax *syntax, struct berval *val, LDAPDN **dn, int flags )); -#define dnPrettyDN(syntax, val, dn) \ - dnPrettyNormalDN((syntax),(val),(dn), SLAP_LDAPDN_PRETTY) -#define dnNormalDN(syntax, val, dn) \ - dnPrettyNormalDN((syntax),(val),(dn), 0) +LDAP_SLAPD_F (int) dnPrettyNormalDN LDAP_P(( Syntax *syntax, struct berval *val, LDAPDN *dn, int flags, void *ctx )); +#define dnPrettyDN(syntax, val, dn, ctx) \ + dnPrettyNormalDN((syntax),(val),(dn), SLAP_LDAPDN_PRETTY, ctx) +#define dnNormalDN(syntax, val, dn, ctx) \ + dnPrettyNormalDN((syntax),(val),(dn), 0, ctx) /* @@ -575,8 +568,8 @@ LDAP_SLAPD_F (int) slap_modrdn2mods( Operation *op, SlapReply *rs, Entry *e, - LDAPRDN *oldrdn, - LDAPRDN *newrdn, + LDAPRDN oldrdn, + LDAPRDN newrdn, Modifications **pmod ); /* @@ -586,7 +579,7 @@ LDAP_SLAPD_F( int ) slap_mods_check( Modifications *ml, int update, const char **text, - char *textbuf, size_t textlen ); + char *textbuf, size_t textlen, void *ctx ); LDAP_SLAPD_F( int ) slap_mods_opattrs( Operation *op, @@ -921,23 +914,9 @@ LDAP_SLAPD_V( int ) schema_init_done; LDAP_SLAPD_F (int) slap_schema_init LDAP_P((void)); LDAP_SLAPD_F (void) schema_destroy LDAP_P(( void )); -LDAP_SLAPD_F( int ) octetStringIndexer( - slap_mask_t use, - slap_mask_t flags, - Syntax *syntax, - MatchingRule *mr, - struct berval *prefix, - BerVarray values, - BerVarray *keysp ); +LDAP_SLAPD_F( slap_mr_indexer_func ) octetStringIndexer; -LDAP_SLAPD_F( int ) octetStringFilter( - slap_mask_t use, - slap_mask_t flags, - Syntax *syntax, - MatchingRule *mr, - struct berval *prefix, - void * assertValue, - BerVarray *keysp ); +LDAP_SLAPD_F( slap_mr_filter_func ) octetStringFilter; /* * schema_prep.c @@ -1016,7 +995,8 @@ LDAP_SLAPD_F (int) asserted_value_validate_normalize LDAP_P(( unsigned usage, struct berval *in, struct berval *out, - const char ** text )); + const char ** text, + void *ctx )); LDAP_SLAPD_F (int) value_match LDAP_P(( int *match, @@ -1030,7 +1010,8 @@ LDAP_SLAPD_F (int) value_find_ex LDAP_P(( AttributeDescription *ad, unsigned flags, BerVarray values, - struct berval *value )); + struct berval *value, + void *ctx )); LDAP_SLAPD_F (int) value_add LDAP_P(( BerVarray *vals, diff --git a/servers/slapd/referral.c b/servers/slapd/referral.c index 4e596ef287..503e1f4558 100644 --- a/servers/slapd/referral.c +++ b/servers/slapd/referral.c @@ -44,7 +44,7 @@ static char * referral_dn_muck( bvin.bv_val = (char *)refDN; bvin.bv_len = strlen( refDN ); - rc = dnPretty2( NULL, &bvin, &nrefDN ); + rc = dnPretty2( NULL, &bvin, &nrefDN, NULL ); if( rc != LDAP_SUCCESS ) { /* Invalid refDN */ return NULL; @@ -59,7 +59,7 @@ static char * referral_dn_muck( return nrefDN.bv_len ? nrefDN.bv_val : ch_strdup( baseDN->bv_val ); } - rc = dnPretty2( NULL, targetDN, &ntargetDN ); + rc = dnPretty2( NULL, targetDN, &ntargetDN, NULL ); if( rc != LDAP_SUCCESS ) { /* Invalid targetDN */ ch_free( nrefDN.bv_val ); @@ -67,7 +67,7 @@ static char * referral_dn_muck( } if( nrefDN.bv_len ) { - rc = dnPretty2( NULL, baseDN, &nbaseDN ); + rc = dnPretty2( NULL, baseDN, &nbaseDN, NULL ); if( rc != LDAP_SUCCESS ) { /* Invalid baseDN */ ch_free( nrefDN.bv_val ); diff --git a/servers/slapd/repl.c b/servers/slapd/repl.c index f37ba4c8ca..8424e73c9c 100644 --- a/servers/slapd/repl.c +++ b/servers/slapd/repl.c @@ -61,7 +61,7 @@ add_replica_suffix( dn.bv_val = (char *) suffix; dn.bv_len = strlen( dn.bv_val ); - rc = dnNormalize2( NULL, &dn, &ndn ); + rc = dnNormalize2( NULL, &dn, &ndn, NULL ); if( rc != LDAP_SUCCESS ) { return 2; } diff --git a/servers/slapd/sasl.c b/servers/slapd/sasl.c index 0b1e1285db..6f95c5edfb 100644 --- a/servers/slapd/sasl.c +++ b/servers/slapd/sasl.c @@ -1532,6 +1532,10 @@ int slap_sasl_getdn( Connection *conn, Operation *op, char *id, int len, id ? ( *id ? id : "" ) : "NULL", len, 0 ); #endif + if ( !op ) { + op = conn->c_sasl_bindop; + } + dn->bv_val = NULL; dn->bv_len = 0; @@ -1606,7 +1610,7 @@ int slap_sasl_getdn( Connection *conn, Operation *op, char *id, int len, /* Build the new dn */ c1 = dn->bv_val; - dn->bv_val = SLAP_MALLOC( len+1 ); + dn->bv_val = sl_malloc( len+1, op->o_tmpmemctx ); if( dn->bv_val == NULL ) { #ifdef NEW_LOGGING LDAP_LOG( TRANSPORT, ERR, @@ -1648,16 +1652,16 @@ int slap_sasl_getdn( Connection *conn, Operation *op, char *id, int len, /* Dup the DN in any case, so we don't risk * leaks or dangling pointers later, * and the DN value is '\0' terminated */ - ber_dupbv( &dn2, dn ); + ber_dupbv_x( &dn2, dn, op->o_tmpmemctx ); dn->bv_val = dn2.bv_val; } /* All strings are in DN form now. Normalize if needed. */ if ( do_norm ) { - rc = dnNormalize2( NULL, dn, &dn2 ); + rc = dnNormalize2( NULL, dn, &dn2, op->o_tmpmemctx ); /* User DNs were constructed above and must be freed now */ - ch_free( dn->bv_val ); + sl_free( dn->bv_val, op->o_tmpmemctx ); if ( rc != LDAP_SUCCESS ) { dn->bv_val = NULL; @@ -1667,14 +1671,10 @@ int slap_sasl_getdn( Connection *conn, Operation *op, char *id, int len, *dn = dn2; } - if ( !op ) { - op = conn->c_sasl_bindop; - } - /* Run thru regexp */ slap_sasl2dn( op, dn, &dn2 ); if( dn2.bv_val ) { - ch_free( dn->bv_val ); + sl_free( dn->bv_val, op->o_tmpmemctx ); *dn = dn2; #ifdef NEW_LOGGING LDAP_LOG( TRANSPORT, ENTRY, diff --git a/servers/slapd/saslauthz.c b/servers/slapd/saslauthz.c index cea19411ce..cb89fe4791 100644 --- a/servers/slapd/saslauthz.c +++ b/servers/slapd/saslauthz.c @@ -94,7 +94,7 @@ static int slap_parseURI( Operation *op, struct berval *uri, is_dn: bv.bv_len = uri->bv_len - (bv.bv_val - uri->bv_val); - rc = dnNormalize2( NULL, &bv, searchbase ); + rc = dnNormalize2( NULL, &bv, searchbase, op->o_tmpmemctx ); if( rc == LDAP_SUCCESS ) { *scope = LDAP_SCOPE_BASE; } @@ -134,7 +134,7 @@ is_dn: bv.bv_len = uri->bv_len - (bv.bv_val - uri->bv_val); /* Grab the searchbase */ bv.bv_val = ludp->lud_dn; bv.bv_len = strlen( bv.bv_val ); - rc = dnNormalize2( NULL, &bv, searchbase ); + rc = dnNormalize2( NULL, &bv, searchbase, op->o_tmpmemctx ); done: if( rc != LDAP_SUCCESS ) { diff --git a/servers/slapd/schema_check.c b/servers/slapd/schema_check.c index 0cc09ddb04..db220385e1 100644 --- a/servers/slapd/schema_check.c +++ b/servers/slapd/schema_check.c @@ -810,7 +810,7 @@ entry_naming_check( char *textbuf, size_t textlen ) { /* naming check */ - LDAPRDN *rdn = NULL; + LDAPRDN rdn = NULL; const char *p = NULL; ber_len_t cnt; int rc = LDAP_SUCCESS; @@ -827,8 +827,8 @@ entry_naming_check( /* Check that each AVA of the RDN is present in the entry */ /* FIXME: Should also check that each AVA lists a distinct type */ - for ( cnt = 0; rdn[0][cnt]; cnt++ ) { - LDAPAVA *ava = rdn[0][cnt]; + for ( cnt = 0; rdn[cnt]; cnt++ ) { + LDAPAVA *ava = rdn[cnt]; AttributeDescription *desc = NULL; Attribute *attr; const char *errtext; @@ -859,7 +859,7 @@ entry_naming_check( if ( value_find_ex( desc, SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH, attr->a_nvals, - &ava->la_value ) != 0 ) + &ava->la_value, NULL ) != 0 ) { snprintf( textbuf, textlen, "value of naming attribute '%s' is not present in entry", diff --git a/servers/slapd/schema_init.c b/servers/slapd/schema_init.c index 4e3f60e5b8..60c14a89a8 100644 --- a/servers/slapd/schema_init.c +++ b/servers/slapd/schema_init.c @@ -124,7 +124,8 @@ int octetStringIndexer( MatchingRule *mr, struct berval *prefix, BerVarray values, - BerVarray *keysp ) + BerVarray *keysp, + void *ctx ) { int i; size_t slen, mlen; @@ -142,7 +143,7 @@ int octetStringIndexer( /* we should have at least one value at this point */ assert( i > 0 ); - keys = ch_malloc( sizeof( struct berval ) * (i+1) ); + keys = sl_malloc( sizeof( struct berval ) * (i+1), ctx ); slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; @@ -161,7 +162,7 @@ int octetStringIndexer( values[i].bv_val, values[i].bv_len ); HASH_Final( HASHdigest, &HASHcontext ); - ber_dupbv( &keys[i], &digest ); + ber_dupbv_x( &keys[i], &digest, ctx ); } keys[i].bv_val = NULL; @@ -180,7 +181,8 @@ int octetStringFilter( MatchingRule *mr, struct berval *prefix, void * assertedValue, - BerVarray *keysp ) + BerVarray *keysp, + void *ctx ) { size_t slen, mlen; BerVarray keys; @@ -194,7 +196,7 @@ int octetStringFilter( slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; - keys = ch_malloc( sizeof( struct berval ) * 2 ); + keys = sl_malloc( sizeof( struct berval ) * 2, ctx ); HASH_Init( &HASHcontext ); if( prefix != NULL && prefix->bv_len > 0 ) { @@ -209,7 +211,7 @@ int octetStringFilter( value->bv_val, value->bv_len ); HASH_Final( HASHdigest, &HASHcontext ); - ber_dupbv( keys, &digest ); + ber_dupbv_x( keys, &digest, ctx ); keys[1].bv_val = NULL; keys[1].bv_len = 0; @@ -351,7 +353,8 @@ octetStringSubstringsIndexer( MatchingRule *mr, struct berval *prefix, BerVarray values, - BerVarray *keysp ) + BerVarray *keysp, + void *ctx ) { ber_len_t i, j, nkeys; size_t slen, mlen; @@ -402,7 +405,7 @@ octetStringSubstringsIndexer( return LDAP_SUCCESS; } - keys = ch_malloc( sizeof( struct berval ) * (nkeys+1) ); + keys = sl_malloc( sizeof( struct berval ) * (nkeys+1), ctx ); slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; @@ -437,7 +440,7 @@ octetStringSubstringsIndexer( SLAP_INDEX_SUBSTR_MAXLEN ); HASH_Final( HASHdigest, &HASHcontext ); - ber_dupbv( &keys[nkeys++], &digest ); + ber_dupbv_x( &keys[nkeys++], &digest, ctx ); } } @@ -464,7 +467,7 @@ octetStringSubstringsIndexer( values[i].bv_val, j ); HASH_Final( HASHdigest, &HASHcontext ); - ber_dupbv( &keys[nkeys++], &digest ); + ber_dupbv_x( &keys[nkeys++], &digest, ctx ); } if( flags & SLAP_INDEX_SUBSTR_FINAL ) { @@ -484,7 +487,7 @@ octetStringSubstringsIndexer( &values[i].bv_val[values[i].bv_len-j], j ); HASH_Final( HASHdigest, &HASHcontext ); - ber_dupbv( &keys[nkeys++], &digest ); + ber_dupbv_x( &keys[nkeys++], &digest, ctx ); } } @@ -510,7 +513,8 @@ octetStringSubstringsFilter ( MatchingRule *mr, struct berval *prefix, void * assertedValue, - BerVarray *keysp ) + BerVarray *keysp, + void *ctx) { SubstringsAssertion *sa; char pre; @@ -559,7 +563,7 @@ octetStringSubstringsFilter ( slen = syntax->ssyn_oidlen; mlen = mr->smr_oidlen; - keys = ch_malloc( sizeof( struct berval ) * (nkeys+1) ); + keys = sl_malloc( sizeof( struct berval ) * (nkeys+1), ctx ); nkeys = 0; if( flags & SLAP_INDEX_SUBSTR_INITIAL && sa->sa_initial.bv_val != NULL && @@ -586,7 +590,7 @@ octetStringSubstringsFilter ( value->bv_val, klen ); HASH_Final( HASHdigest, &HASHcontext ); - ber_dupbv( &keys[nkeys++], &digest ); + ber_dupbv_x( &keys[nkeys++], &digest, ctx ); } if( flags & SLAP_INDEX_SUBSTR_ANY && sa->sa_any != NULL ) { @@ -620,7 +624,7 @@ octetStringSubstringsFilter ( &value->bv_val[j], klen ); HASH_Final( HASHdigest, &HASHcontext ); - ber_dupbv( &keys[nkeys++], &digest ); + ber_dupbv_x( &keys[nkeys++], &digest, ctx ); } } } @@ -649,7 +653,7 @@ octetStringSubstringsFilter ( &value->bv_val[value->bv_len-klen], klen ); HASH_Final( HASHdigest, &HASHcontext ); - ber_dupbv( &keys[nkeys++], &digest ); + ber_dupbv_x( &keys[nkeys++], &digest, ctx ); } if( nkeys > 0 ) { @@ -746,7 +750,8 @@ uniqueMemberNormalize( Syntax *syntax, MatchingRule *mr, struct berval *val, - struct berval *normalized ) + struct berval *normalized, + void *ctx ) { struct berval out; int rc; @@ -773,7 +778,7 @@ uniqueMemberNormalize( *(uid.bv_val++) = '\0'; } - rc = dnNormalize2( NULL, &out, normalized ); + rc = dnNormalize2( NULL, &out, normalized, ctx ); if( rc != LDAP_SUCCESS ) { free( out.bv_val ); @@ -982,7 +987,8 @@ UTF8StringNormalize( Syntax *syntax, MatchingRule *mr, struct berval *val, - struct berval *normalized ) + struct berval *normalized, + void *ctx ) { struct berval tmp, nvalue; int flags; @@ -1393,14 +1399,15 @@ telephoneNumberNormalize( Syntax *syntax, MatchingRule *mr, struct berval *val, - struct berval *normalized ) + struct berval *normalized, + void *ctx ) { char *p, *q; /* validator should have refused an empty string */ assert( val->bv_len ); - q = normalized->bv_val = ch_malloc( val->bv_len + 1 ); + q = normalized->bv_val = sl_malloc( val->bv_len + 1, ctx ); for( p = val->bv_val; *p; p++ ) { if ( ! ( ASCII_SPACE( *p ) || *p == '-' )) { @@ -1412,7 +1419,7 @@ telephoneNumberNormalize( normalized->bv_len = q - normalized->bv_val; if( normalized->bv_len == 0 ) { - free( normalized->bv_val ); + sl_free( normalized->bv_val, ctx ); return LDAP_INVALID_SYNTAX; } @@ -1542,7 +1549,8 @@ integerNormalize( Syntax *syntax, MatchingRule *mr, struct berval *val, - struct berval *normalized ) + struct berval *normalized, + void *ctx ) { char *p; int negative=0; @@ -1575,12 +1583,12 @@ integerNormalize( /* If there are no non-zero digits left, the number is zero, otherwise allocate space for the number and copy it into the buffer */ if( len == 0 ) { - normalized->bv_val = ch_strdup("0"); + normalized->bv_val = ber_strdup_x("0", ctx); normalized->bv_len = 1; } else { normalized->bv_len = len+negative; - normalized->bv_val = ch_malloc( normalized->bv_len + 1 ); + normalized->bv_val = sl_malloc( normalized->bv_len + 1, ctx ); if( negative ) normalized->bv_val[0] = '-'; AC_MEMCPY( normalized->bv_val + negative, p, len ); normalized->bv_val[len+negative] = '\0'; @@ -1680,7 +1688,8 @@ IA5StringNormalize( Syntax *syntax, MatchingRule *mr, struct berval *val, - struct berval *normalized ) + struct berval *normalized, + void *ctx ) { char *p, *q; int casefold = (mr != slap_schema.si_mr_caseExactIA5Match); @@ -1694,7 +1703,7 @@ IA5StringNormalize( p++; } - normalized->bv_val = ch_strdup( p ); + normalized->bv_val = ber_strdup_x( p, ctx ); p = q = normalized->bv_val; while ( *p ) { @@ -1734,7 +1743,7 @@ IA5StringNormalize( normalized->bv_len = q - normalized->bv_val; if( normalized->bv_len == 0 ) { - normalized->bv_val = ch_realloc( normalized->bv_val, 2 ); + normalized->bv_val = sl_realloc( normalized->bv_val, 2, ctx ); normalized->bv_val[0] = ' '; normalized->bv_val[1] = '\0'; normalized->bv_len = 1; @@ -1767,14 +1776,15 @@ numericStringNormalize( Syntax *syntax, MatchingRule *mr, struct berval *val, - struct berval *normalized ) + struct berval *normalized, + void *ctx ) { /* removal all spaces */ char *p, *q; assert( val->bv_len ); - normalized->bv_val = ch_malloc( val->bv_len + 1 ); + normalized->bv_val = sl_malloc( val->bv_len + 1, ctx ); p = val->bv_val; q = normalized->bv_val; @@ -1797,7 +1807,7 @@ numericStringNormalize( normalized->bv_len = q - normalized->bv_val; if( normalized->bv_len == 0 ) { - normalized->bv_val = ch_realloc( normalized->bv_val, 2 ); + normalized->bv_val = sl_realloc( normalized->bv_val, 2, ctx ); normalized->bv_val[0] = ' '; normalized->bv_val[1] = '\0'; normalized->bv_len = 1; @@ -2534,7 +2544,8 @@ generalizedTimeNormalize( Syntax *syntax, MatchingRule *mr, struct berval *val, - struct berval *normalized ) + struct berval *normalized, + void *ctx ) { int parts[9], rc; @@ -2543,7 +2554,7 @@ generalizedTimeNormalize( return rc; } - normalized->bv_val = ch_malloc( 16 ); + normalized->bv_val = sl_malloc( 16, ctx ); if ( normalized->bv_val == NULL ) { return LBER_ERROR_MEMORY; } diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index 9a3ee2526e..086c023905 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -28,14 +28,15 @@ static int objectClassNormalize( struct slap_syntax *syntax, /* NULL if in is asserted value */ struct slap_matching_rule *mr, struct berval * in, - struct berval * out ) + struct berval * out, + void *ctx ) { ObjectClass *oc = oc_bvfind( in ); if( oc != NULL ) { - ber_dupbv( out, &oc->soc_cname ); + ber_dupbv_x( out, &oc->soc_cname, ctx ); } else { - ber_dupbv( out, in ); + ber_dupbv_x( out, in, ctx ); } #if OCDEBUG @@ -118,7 +119,8 @@ static int objectSubClassIndexer( struct slap_matching_rule *mr, struct berval *prefix, BerVarray values, - BerVarray *keysp ) + BerVarray *keysp, + void *ctx ) { int rc, noc, i; BerVarray ocvalues; @@ -128,7 +130,7 @@ static int objectSubClassIndexer( } /* over allocate */ - ocvalues = ch_malloc( sizeof( struct berval ) * (noc+16) ); + ocvalues = sl_malloc( sizeof( struct berval ) * (noc+16), ctx ); /* copy listed values (and termination) */ for( i=0; isr_err = dnPrettyNormal( NULL, &base, &op->o_req_dn, &op->o_req_ndn ); + rs->sr_err = dnPrettyNormal( NULL, &base, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx ); if( rs->sr_err != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, ERR, @@ -318,11 +318,11 @@ do_search( } if( !op->o_req_ndn.bv_len && default_search_nbase.bv_len ) { - ch_free( op->o_req_dn.bv_val ); - ch_free( op->o_req_ndn.bv_val ); + sl_free( op->o_req_dn.bv_val, op->o_tmpmemctx ); + sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx ); - ber_dupbv( &op->o_req_dn, &default_search_base ); - ber_dupbv( &op->o_req_ndn, &default_search_nbase ); + ber_dupbv_x( &op->o_req_dn, &default_search_base, op->o_tmpmemctx ); + ber_dupbv_x( &op->o_req_ndn, &default_search_nbase, op->o_tmpmemctx ); } /* @@ -392,8 +392,8 @@ return_results:; return rs->sr_err; #endif - if( op->o_req_dn.bv_val != NULL) free( op->o_req_dn.bv_val ); - if( op->o_req_ndn.bv_val != NULL) free( op->o_req_ndn.bv_val ); + if( op->o_req_dn.bv_val != NULL) sl_free( op->o_req_dn.bv_val, op->o_tmpmemctx ); + if( op->o_req_ndn.bv_val != NULL) sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx ); if( op->ors_filterstr.bv_val != NULL) op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx ); if( op->ors_filter != NULL) filter_free_x( op, op->ors_filter ); diff --git a/servers/slapd/sl_malloc.c b/servers/slapd/sl_malloc.c index 6d81abeab8..8e037662d7 100644 --- a/servers/slapd/sl_malloc.c +++ b/servers/slapd/sl_malloc.c @@ -129,7 +129,7 @@ sl_realloc( void *ptr, ber_len_t size, void *ctx ) if ( ptr == NULL ) return sl_malloc( size, ctx ); /* Not our memory? */ - if ( ptr < sh->h_base || ptr >= sh->h_end ) { + if ( !sh || ptr < sh->h_base || ptr >= sh->h_end ) { return ch_realloc( ptr, size ); } @@ -154,7 +154,7 @@ sl_free( void *ptr, void *ctx ) { struct slab_heap *sh = ctx; - if ( ptr < sh->h_base || ptr >= sh->h_end ) { + if ( !sh || ptr < sh->h_base || ptr >= sh->h_end ) { ch_free( ptr ); } } @@ -164,7 +164,7 @@ sl_release( void *ptr, void *ctx ) { struct slab_heap *sh = ctx; - if ( ptr >= sh->h_base && ptr <= sh->h_end ) { + if ( sh && ptr >= sh->h_base && ptr <= sh->h_end ) { sh->h_last = ptr; } } @@ -173,6 +173,9 @@ void * sl_mark( void *ctx ) { struct slab_heap *sh = ctx; + void *ret = NULL; - return sh->h_last; + if (sh) ret = sh->h_last; + + return ret; } diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index 8ae1b3ad2c..1ca24c3927 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -292,7 +292,8 @@ typedef int slap_syntax_validate_func LDAP_P(( typedef int slap_syntax_transform_func LDAP_P(( struct slap_syntax *syntax, struct berval * in, - struct berval * out)); + struct berval * out, + void *memctx)); typedef struct slap_syntax { LDAPSyntax ssyn_syn; @@ -350,7 +351,8 @@ typedef struct slap_syntax_defs_rec { /* X -> Y Converter */ typedef int slap_mr_convert_func LDAP_P(( struct berval * in, - struct berval * out )); + struct berval * out, + void *memctx )); /* Normalizer */ typedef int slap_mr_normalize_func LDAP_P(( @@ -358,7 +360,8 @@ typedef int slap_mr_normalize_func LDAP_P(( struct slap_syntax *syntax, /* NULL if in is asserted value */ struct slap_matching_rule *mr, struct berval * in, - struct berval * out )); + struct berval * out, + void *memctx )); /* Match (compare) function */ typedef int slap_mr_match_func LDAP_P(( @@ -377,7 +380,8 @@ typedef int slap_mr_indexer_func LDAP_P(( struct slap_matching_rule *mr, struct berval *prefix, BerVarray values, - BerVarray *keys )); + BerVarray *keys, + void *memctx )); /* Filter index function */ typedef int slap_mr_filter_func LDAP_P(( @@ -387,7 +391,8 @@ typedef int slap_mr_filter_func LDAP_P(( struct slap_matching_rule *mr, struct berval *prefix, void * assertValue, - BerVarray *keys )); + BerVarray *keys, + void *memctx )); typedef struct slap_matching_rule_use MatchingRuleUse; diff --git a/servers/slapd/slapi/slapi_ops.c b/servers/slapd/slapi/slapi_ops.c index 5e3f4992cf..bc1e84cea8 100644 --- a/servers/slapd/slapi/slapi_ops.c +++ b/servers/slapd/slapi/slapi_ops.c @@ -351,7 +351,7 @@ LDAPModToEntry( dn.bv_val = slapi_ch_strdup(ldn); dn.bv_len = strlen(ldn); - rc = dnPrettyNormal( NULL, &dn, &pEntry->e_name, &pEntry->e_nname ); + rc = dnPrettyNormal( NULL, &dn, &pEntry->e_name, &pEntry->e_nname, NULL ); if ( rc != LDAP_SUCCESS ) goto cleanup; @@ -420,7 +420,7 @@ LDAPModToEntry( size_t textlen = sizeof textbuf; rc = slap_mods_check( modlist, update, &text, - textbuf, textlen ); + textbuf, textlen, NULL ); if ( rc != LDAP_SUCCESS) { goto cleanup; } @@ -511,7 +511,7 @@ slapi_delete_internal( dn.bv_val = slapi_ch_strdup(ldn); dn.bv_len = strlen(ldn); - rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn ); + rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL ); if ( rs.sr_err != LDAP_SUCCESS ) goto cleanup; @@ -751,7 +751,7 @@ slapi_modrdn_internal( dn.bv_val = slapi_ch_strdup( olddn ); dn.bv_len = strlen( olddn ); - rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn ); + rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL ); if ( rs.sr_err != LDAP_SUCCESS ) { goto cleanup; } @@ -764,7 +764,7 @@ slapi_modrdn_internal( newrdn.bv_val = slapi_ch_strdup( lnewrdn ); newrdn.bv_len = strlen( lnewrdn ); - rs.sr_err = dnPrettyNormal( NULL, &newrdn, &op->oq_modrdn.rs_newrdn, &op->oq_modrdn.rs_nnewrdn ); + rs.sr_err = dnPrettyNormal( NULL, &newrdn, &op->oq_modrdn.rs_newrdn, &op->oq_modrdn.rs_nnewrdn, NULL ); if ( rs.sr_err != LDAP_SUCCESS ) { goto cleanup; } @@ -876,7 +876,7 @@ slapi_modify_internal( dn.bv_val = slapi_ch_strdup( ldn ); dn.bv_len = strlen( ldn ); - rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn ); + rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL ); if ( rs.sr_err != LDAP_SUCCESS ) { goto cleanup; } @@ -979,7 +979,7 @@ slapi_modify_internal( size_t textlen = sizeof( textbuf ); rs.sr_err = slap_mods_check( modlist, update, - &text, textbuf, textlen ); + &text, textbuf, textlen, NULL ); if ( rs.sr_err != LDAP_SUCCESS ) { goto cleanup; } @@ -1069,7 +1069,7 @@ slapi_search_internal_bind( dn.bv_val = slapi_ch_strdup(ldn); dn.bv_len = strlen(ldn); - rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn ); + rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL ); if ( rs.sr_err != LDAP_SUCCESS ) { goto cleanup; } diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index 74812f822e..9aece919aa 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -161,7 +161,7 @@ slapi_entry_set_dn( dn.bv_val = ldn; dn.bv_len = strlen( ldn ); - dnPrettyNormal( NULL, &dn, &e->e_name, &e->e_nname ); + dnPrettyNormal( NULL, &dn, &e->e_name, &e->e_nname, NULL ); #endif /* LDAP_SLAPI */ } @@ -857,7 +857,7 @@ slapi_dn_normalize( char *dn ) bdn.bv_val = dn; bdn.bv_len = strlen( dn ); - dnNormalize2( NULL, &bdn, &ndn ); + dnNormalize2( NULL, &bdn, &ndn, NULL ); /* * FIXME: ain't it safe to set dn = ndn.bv_val ? @@ -909,11 +909,11 @@ slapi_dn_issuffix( bsuffix.bv_val = suffix; bsuffix.bv_len = strlen( suffix ); - if ( dnNormalize2( NULL, &bdn, &ndn ) != LDAP_SUCCESS ) { + if ( dnNormalize2( NULL, &bdn, &ndn, NULL ) != LDAP_SUCCESS ) { return 0; } - if ( dnNormalize2( NULL, &bsuffix, &nsuffix ) != LDAP_SUCCESS ) { + if ( dnNormalize2( NULL, &bsuffix, &nsuffix, NULL ) != LDAP_SUCCESS ) { slapi_ch_free( (void **)&ndn.bv_val ); return 0; } diff --git a/servers/slapd/tools/Makefile.in b/servers/slapd/tools/Makefile.in index 534c80094f..63635c819f 100644 --- a/servers/slapd/tools/Makefile.in +++ b/servers/slapd/tools/Makefile.in @@ -46,7 +46,7 @@ SLAPD_OBJS = ../globals.o ../config.o ../ch_malloc.o ../cr.o ../backend.o \ ../init.o ../controls.o ../kerberos.o ../passwd.o \ ../index.o ../extended.o ../starttls.o ../sets.o ../mra.o \ ../referral.o ../backglue.o ../oidm.o ../mods.o ../operation.o \ - ../cancel.o + ../cancel.o ../sl_malloc.o SLAPOBJS = $(SLAPD_OBJS) slapcommon.o mimic.o diff --git a/servers/slapd/tools/mimic.c b/servers/slapd/tools/mimic.c index c05600417b..e319fa3a12 100644 --- a/servers/slapd/tools/mimic.c +++ b/servers/slapd/tools/mimic.c @@ -199,8 +199,8 @@ int slap_modrdn2mods( Operation *op, SlapReply *rs, Entry *e, - LDAPRDN *oldrdn, - LDAPRDN *newrdn, + LDAPRDN oldrdn, + LDAPRDN newrdn, Modifications **pmod ) { return 0; @@ -217,7 +217,7 @@ slap_mods2entry( return 0; } -int slap_sasl_getdn( Connection *conn, char *id, int len, +int slap_sasl_getdn( Connection *conn, Operation *op, char *id, int len, char *user_realm, struct berval *dn, int flags ) { return -1; diff --git a/servers/slapd/tools/slapcommon.c b/servers/slapd/tools/slapcommon.c index d78f3bc0c2..2f1255d8f6 100644 --- a/servers/slapd/tools/slapcommon.c +++ b/servers/slapd/tools/slapcommon.c @@ -232,7 +232,7 @@ slap_tool_init( if( base.bv_val != NULL ) { struct berval nbase; - rc = dnNormalize2( NULL, &base, &nbase ); + rc = dnNormalize2( NULL, &base, &nbase, NULL ); if( rc != LDAP_SUCCESS ) { fprintf( stderr, "%s: slap_init invalid suffix (\"%s\")\n", progname, base.bv_val ); diff --git a/servers/slapd/value.c b/servers/slapd/value.c index 0d70a7c611..f7cd45c014 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -129,7 +129,8 @@ int asserted_value_validate_normalize( unsigned usage, struct berval *in, struct berval *out, - const char ** text ) + const char ** text, + void *ctx ) { int rc; @@ -156,7 +157,7 @@ int asserted_value_validate_normalize( if( mr->smr_normalize ) { rc = (mr->smr_normalize)( usage, ad ? ad->ad_type->sat_syntax : NULL, - mr, in, out ); + mr, in, out, ctx ); if( rc != LDAP_SUCCESS ) { *text = "unable to normalize value for matching"; @@ -164,7 +165,7 @@ int asserted_value_validate_normalize( } } else { - ber_dupbv( out, in ); + ber_dupbv_x( out, in, ctx ); } return LDAP_SUCCESS; @@ -207,7 +208,8 @@ int value_find_ex( AttributeDescription *ad, unsigned flags, BerVarray vals, - struct berval *val ) + struct berval *val, + void *ctx ) { int i; int rc; @@ -226,7 +228,7 @@ int value_find_ex( rc = (mr->smr_normalize)( flags & SLAP_MR_TYPE_MASK|SLAP_MR_SUBTYPE_MASK, ad ? ad->ad_type->sat_syntax : NULL, - mr, val, &nval ); + mr, val, &nval, ctx ); if( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; @@ -246,6 +248,6 @@ int value_find_ex( } } - free( nval.bv_val ); + ber_memfree_x( nval.bv_val, ctx ); return LDAP_NO_SUCH_ATTRIBUTE; } -- 2.39.5