X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=servers%2Fslapd%2Fcomponent.c;h=813c8bfe31aaef0a5c0d16f5fc23bd32b2ffde6f;hb=5fcc9285fb8c549a5264921a2b61cfc40803d720;hp=bb66c4cee7bc23a1f230db690e5f664bf5a3c3bd;hpb=9d59266e25dbeae63428f55f10588e4a78586b34;p=openldap diff --git a/servers/slapd/component.c b/servers/slapd/component.c index bb66c4cee7..813c8bfe31 100644 --- a/servers/slapd/component.c +++ b/servers/slapd/component.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 2003-2005 The OpenLDAP Foundation. + * Copyright 2003-2012 The OpenLDAP Foundation. * Portions Copyright 2004 by IBM Corporation. * All rights reserved. * @@ -99,7 +99,7 @@ componentFilterMatch ( { ComponentSyntaxInfo *csi_attr = (ComponentSyntaxInfo*)value; MatchingRuleAssertion * ma = (MatchingRuleAssertion*)assertedValue; - int num_attr, rc, i; + int rc; if ( !mr || !ma->ma_cf ) return LDAP_INAPPROPRIATE_MATCHING; @@ -154,8 +154,6 @@ allComponentsMatch( static int slapd_ber2cav( struct berval* bv, ComponentAssertionValue* cav ) { - int len; - cav->cav_ptr = cav->cav_buf = bv->bv_val; cav->cav_end = bv->bv_val + bv->bv_len; @@ -165,11 +163,9 @@ slapd_ber2cav( struct berval* bv, ComponentAssertionValue* cav ) ComponentReference* dup_comp_ref ( Operation* op, ComponentReference* cr ) { - int rc, count = 0; ComponentReference* dup_cr; ComponentId* ci_curr; ComponentId** ci_temp; - ber_int_t type; dup_cr = op->o_tmpalloc( sizeof( ComponentReference ), op->o_tmpmemctx ); @@ -183,7 +179,7 @@ dup_comp_ref ( Operation* op, ComponentReference* cr ) ci_curr = ci_curr->ci_next, ci_temp = &(*ci_temp)->ci_next ) { *ci_temp = op->o_tmpalloc( sizeof( ComponentId ), op->o_tmpmemctx ); - if ( !ci_temp ) return NULL; + if ( !*ci_temp ) return NULL; **ci_temp = *ci_curr; } @@ -216,7 +212,7 @@ dup_comp_filter_list ( int get_len_of_next_assert_value ( struct berval* bv, char separator ) { - int i = 0; + ber_len_t i = 0; while (1) { if ( (bv->bv_val[ i ] == separator) || ( i >= bv->bv_len) ) break; @@ -234,7 +230,6 @@ dup_comp_filter_item ( ComponentAssertion* in_ca, ComponentAssertion** out_ca ) { - ComponentAssertion* ca; int len; if ( !in_ca->ca_comp_ref ) return SLAPD_DISCONNECT; @@ -301,9 +296,7 @@ dup_comp_filter ( int get_aliased_filter_aa ( Operation* op, AttributeAssertion* a_assert, AttributeAliasing* aa, const char** text ) { - int rc; struct berval assert_bv; - ComponentAssertion* ca; Debug( LDAP_DEBUG_FILTER, "get_aliased_filter\n", 0, 0, 0 ); @@ -324,9 +317,7 @@ get_aliased_filter( Operation* op, MatchingRuleAssertion* ma, AttributeAliasing* aa, const char** text ) { - int rc; struct berval assert_bv; - ComponentAssertion* ca; Debug( LDAP_DEBUG_FILTER, "get_aliased_filter\n", 0, 0, 0 ); @@ -447,7 +438,8 @@ get_componentId( Operation *op, ComponentAssertionValue* cav, type = peek_componentId_type( cav ); - Debug( LDAP_DEBUG_FILTER, "get_compId [%d]\n", type, 0, 0 ); + Debug( LDAP_DEBUG_FILTER, "get_compId [%lu]\n", + (unsigned long) type, 0, 0 ); len = 0; _cid.ci_type = type; _cid.ci_next = NULL; @@ -499,7 +491,10 @@ get_componentId( Operation *op, ComponentAssertionValue* cav, if ( op ) { *cid = op->o_tmpalloc( sizeof( ComponentId ), op->o_tmpmemctx ); } else { - *cid = malloc( sizeof( ComponentId ) ); + *cid = SLAP_MALLOC( sizeof( ComponentId ) ); + } + if (*cid == NULL) { + return LDAP_NO_MEMORY; } **cid = _cid; return LDAP_SUCCESS; @@ -572,7 +567,7 @@ get_component_reference( ca_comp_ref = op->o_tmpalloc( sizeof( ComponentReference ), op->o_tmpmemctx ); } else { - ca_comp_ref = malloc( sizeof( ComponentReference ) ); + ca_comp_ref = SLAP_MALLOC( sizeof( ComponentReference ) ); } if ( !ca_comp_ref ) return LDAP_NO_MEMORY; @@ -588,6 +583,11 @@ get_component_reference( cr_list = &(*cr_list)->ci_next; } else if ( rc == LDAP_COMPREF_UNDEFINED ) { + if ( op ) { + op->o_tmpfree( ca_comp_ref , op->o_tmpmemctx ); + } else { + free( ca_comp_ref ); + } return rc; } } @@ -602,16 +602,8 @@ get_component_reference( return rc; } - if ( rc == LDAP_SUCCESS ) { - *cr = ca_comp_ref; - **cr = *ca_comp_ref; - - } else if ( op ) { - op->o_tmpfree( ca_comp_ref , op->o_tmpmemctx ); - - } else { - free( ca_comp_ref ) ; - } + *cr = ca_comp_ref; + **cr = *ca_comp_ref; (*cr)->cr_string.bv_val = start; (*cr)->cr_string.bv_len = end - start + 1; @@ -910,7 +902,7 @@ strip_cav_str( ComponentAssertionValue* cav, char* str) /* * TAG : "item", "and", "or", "not" */ -static int +static ber_tag_t strip_cav_tag( ComponentAssertionValue* cav ) { @@ -955,7 +947,6 @@ get_item( Operation *op, ComponentAssertionValue* cav, ComponentAssertion** ca, { int rc; ComponentAssertion* _ca; - struct berval t_bv; struct berval value; MatchingRule* mr; @@ -963,7 +954,7 @@ get_item( Operation *op, ComponentAssertionValue* cav, ComponentAssertion** ca, if ( op ) _ca = op->o_tmpalloc( sizeof( ComponentAssertion ), op->o_tmpmemctx ); else - _ca = malloc( sizeof( ComponentAssertion ) ); + _ca = SLAP_MALLOC( sizeof( ComponentAssertion ) ); if ( !_ca ) return LDAP_NO_MEMORY; @@ -1085,7 +1076,7 @@ parse_comp_filter( Operation* op, ComponentAssertionValue* cav, ber_tag_t tag; int err; ComponentFilter f; - /* TAG : item, and, or, not in RFC 2254 */ + /* TAG : item, and, or, not in RFC 4515 */ tag = strip_cav_tag( cav ); if ( tag == LBER_ERROR ) { @@ -1182,7 +1173,10 @@ parse_comp_filter( Operation* op, ComponentAssertionValue* cav, if ( op ) { *filt = op->o_tmpalloc( sizeof(f), op->o_tmpmemctx ); } else { - *filt = malloc( sizeof(f) ); + *filt = SLAP_MALLOC( sizeof(f) ); + } + if ( *filt == NULL ) { + return LDAP_NO_MEMORY; } **filt = f; } @@ -1267,7 +1261,7 @@ test_comp_filter_item( ComponentSyntaxInfo *csi_attr, ComponentAssertion *ca ) { - int rc, len; + int rc; void *attr_nm, *assert_nm; if ( strcmp(ca->ca_ma_rule->smr_mrule.mr_oid,