Commit f1427fd8 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

remap compare attribute; fix erroneous pointers; minor cleanup

parent ba6ac023
......@@ -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;
......
......@@ -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];
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment