From: Pierangelo Masarati Date: Thu, 30 Dec 2004 17:46:38 +0000 (+0000) Subject: remap compare attribute; fix erroneous pointers; minor cleanup X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~7^2~3 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f1427fd87107859dd26ef55323f44240873cdf99;p=openldap remap compare attribute; fix erroneous pointers; minor cleanup --- diff --git a/servers/slapd/overlays/rwm.c b/servers/slapd/overlays/rwm.c index f6f5179eda..1c1da03a81 100644 --- a/servers/slapd/overlays/rwm.c +++ b/servers/slapd/overlays/rwm.c @@ -263,14 +263,22 @@ rwm_op_compare( Operation *op, SlapReply *rs ) mapped_at = op->orc_ava->aa_desc->ad_cname; } else { - rwm_map( &rwmap->rwm_at, &op->orc_ava->aa_desc->ad_cname, - &mapped_at, RWM_MAP ); - if ( BER_BVISNULL( &mapped_at ) || BER_BVISEMPTY( &mapped_at ) ) - { - op->o_bd->bd_info = (BackendInfo *)on->on_info; - send_ldap_error( op, rs, LDAP_OTHER, "compare attributeType map error" ); - return -1; + struct ldapmapping *mapping = NULL; + AttributeDescription *ad = op->orc_ava->aa_desc; + + ( void )rwm_mapping( &rwmap->rwm_at, &op->orc_ava->aa_desc->ad_cname, + &mapping, RWM_MAP ); + if ( mapping == NULL ) { + if ( rwmap->rwm_at.drop_missing ) { + op->o_bd->bd_info = (BackendInfo *)on->on_info; + send_ldap_error( op, rs, LDAP_OTHER, "compare attributeType map error" ); + return -1; + } + + } else { + ad = mapping->m_dst_ad; } + if ( op->orc_ava->aa_desc->ad_type->sat_syntax == slap_schema.si_syn_distinguishedName ) { struct berval *mapped_valsp[2]; @@ -295,6 +303,7 @@ rwm_op_compare( Operation *op, SlapReply *rs ) op->orc_ava->aa_value = mapped_vals[0]; } + op->orc_ava->aa_desc = ad; } return SLAP_CB_CONTINUE; diff --git a/servers/slapd/overlays/rwmmap.c b/servers/slapd/overlays/rwmmap.c index 3a29f3ed21..033e84b51c 100644 --- a/servers/slapd/overlays/rwmmap.c +++ b/servers/slapd/overlays/rwmmap.c @@ -136,7 +136,7 @@ rwm_map( struct ldapmap *map, struct berval *s, struct berval *bv, int remap ) struct ldapmapping *mapping; BER_BVZERO( bv ); - rwm_mapping( map, s, &mapping, remap ); + ( void )rwm_mapping( map, s, &mapping, remap ); if ( mapping != NULL ) { if ( !BER_BVISNULL( &mapping->m_dst ) ) { *bv = mapping->m_dst; @@ -702,7 +702,8 @@ rwm_filter_map_rewrite( switch ( rewrite_session( fdc.rwmap->rwm_rw, fdc.ctx, ( !BER_BVISEMPTY( &ftmp ) ? ftmp.bv_val : "" ), - fdc.conn, &fstr->bv_val )) { + fdc.conn, &fstr->bv_val ) ) + { case REWRITE_REGEXEC_OK: if ( !BER_BVISNULL( fstr ) ) { fstr->bv_len = strlen( fstr->bv_val ); @@ -714,7 +715,7 @@ rwm_filter_map_rewrite( Debug( LDAP_DEBUG_ARGS, "[rw] %s: \"%s\" -> \"%s\"\n", - dc->ctx, ftmp.bv_val, fstr->bv_val ); + fdc.ctx, ftmp.bv_val, fstr->bv_val ); rc = LDAP_SUCCESS; break; @@ -1031,12 +1032,13 @@ rwm_referral_result_rewrite( * legal to trim values when adding/modifying; * it should be when searching (e.g. ACLs). */ - ch_free( &a_vals[i].bv_val ); + ch_free( a_vals[i].bv_val ); if ( last > i ) { a_vals[i] = a_vals[last]; } BER_BVZERO( &a_vals[last] ); last--; + i--; break; default: @@ -1089,7 +1091,7 @@ rwm_dnattr_result_rewrite( * legal to trim values when adding/modifying; * it should be when searching (e.g. ACLs). */ - ch_free( &a_vals[i].bv_val ); + ch_free( a_vals[i].bv_val ); if ( last > i ) { a_vals[i] = a_vals[last]; }