mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-06 10:46:21 +08:00
ITS#5977 strip duplicates out of sorted attrs
This commit is contained in:
parent
62eeafa1d9
commit
755e645da3
@ -1801,6 +1801,7 @@ meta_send_entry(
|
|||||||
metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
|
metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
|
||||||
struct berval a, mapped;
|
struct berval a, mapped;
|
||||||
int check_duplicate_attrs = 0;
|
int check_duplicate_attrs = 0;
|
||||||
|
int check_sorted_attrs = 0;
|
||||||
Entry ent = { 0 };
|
Entry ent = { 0 };
|
||||||
BerElement ber = *e->lm_ber;
|
BerElement ber = *e->lm_ber;
|
||||||
Attribute *attr, **attrp;
|
Attribute *attr, **attrp;
|
||||||
@ -1925,6 +1926,9 @@ meta_send_entry(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( attr->a_desc->ad_type->sat_flags & SLAP_AT_SORTED_VAL )
|
||||||
|
check_sorted_attrs = 1;
|
||||||
|
|
||||||
/* no subschemaSubentry */
|
/* no subschemaSubentry */
|
||||||
if ( attr->a_desc == slap_schema.si_ad_subschemaSubentry
|
if ( attr->a_desc == slap_schema.si_ad_subschemaSubentry
|
||||||
|| attr->a_desc == slap_schema.si_ad_entryDN )
|
|| attr->a_desc == slap_schema.si_ad_entryDN )
|
||||||
@ -2157,6 +2161,34 @@ next_attr:;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check for sorted attributes */
|
||||||
|
if ( check_sorted_attrs ) {
|
||||||
|
for ( attr = ent.e_attrs; attr; attr = attr->a_next ) {
|
||||||
|
if ( attr->a_desc->ad_type->sat_flags & SLAP_AT_SORTED_VAL ) {
|
||||||
|
while ( attr->a_numvals > 1 ) {
|
||||||
|
int i;
|
||||||
|
int rc = slap_sort_vals( (Modifications *)attr, &text, &i, op->o_tmpmemctx );
|
||||||
|
if ( rc != LDAP_TYPE_OR_VALUE_EXISTS )
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Strip duplicate values */
|
||||||
|
if ( attr->a_nvals != attr->a_vals )
|
||||||
|
LBER_FREE( attr->a_nvals[i].bv_val );
|
||||||
|
LBER_FREE( attr->a_vals[i].bv_val );
|
||||||
|
attr->a_numvals--;
|
||||||
|
if ( i < attr->a_numvals ) {
|
||||||
|
attr->a_vals[i] = attr->a_vals[attr->a_numvals];
|
||||||
|
if ( attr->a_nvals != attr->a_vals )
|
||||||
|
attr->a_nvals[i] = attr->a_nvals[attr->a_numvals];
|
||||||
|
}
|
||||||
|
BER_BVZERO(&attr->a_vals[attr->a_numvals]);
|
||||||
|
if ( attr->a_nvals != attr->a_vals )
|
||||||
|
BER_BVZERO(&attr->a_vals[attr->a_numvals]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ldap_get_entry_controls( mc->mc_conns[target].msc_ld,
|
ldap_get_entry_controls( mc->mc_conns[target].msc_ld,
|
||||||
e, &rs->sr_ctrls );
|
e, &rs->sr_ctrls );
|
||||||
rs->sr_entry = &ent;
|
rs->sr_entry = &ent;
|
||||||
|
Loading…
Reference in New Issue
Block a user