/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2003-2007 The OpenLDAP Foundation.
+ * Copyright 2003-2008 The OpenLDAP Foundation.
* Portions Copyright 2003 Pierangelo Masarati.
* All rights reserved.
*
{
int j, last;
- for ( last = 0; !BER_BVISNULL( &(*ap)->a_vals[ last ] ); last++ )
- /* count values */ ;
- last--;
+ last = (*ap)->a_numvals - 1;
for ( j = 0; !BER_BVISNULL( &(*ap)->a_vals[ j ] ); j++ ) {
struct ldapmapping *mapping = NULL;
(*ap)->a_vals[ j ] = (*ap)->a_vals[ last ];
}
BER_BVZERO( &(*ap)->a_vals[ last ] );
+ (*ap)->a_numvals--;
last--;
j--;
}
}
if ( !BER_BVISNULL( &id ) ) {
+ char idNul = id.bv_val[id.bv_len];
+ id.bv_val[id.bv_len] = '\0';
rs->sr_err = dnPrettyNormal( NULL, &id, &op->o_req_dn,
&op->o_req_ndn, op->o_tmpmemctx );
+ id.bv_val[id.bv_len] = idNul;
if ( rs->sr_err != LDAP_SUCCESS ) {
rs->sr_text = "Invalid DN";
return rs->sr_err;
mapping->m_dst_ad->ad_type->sat_equality->smr_normalize )
{
int i = 0;
- for ( last = 0; !BER_BVISNULL( &(*ap)->a_vals[last] ); last++ )
- /* just count */ ;
+ last = (*ap)->a_numvals;
if ( last )
{
(*ap)->a_nvals = ch_malloc( (last+1) * sizeof(struct berval) );
}
if ( last == -1 ) { /* not yet counted */
- for ( last = 0; !BER_BVISNULL( &(*ap)->a_vals[last] ); last++ )
- /* just count */ ;
+ last = (*ap)->a_numvals;
}
if ( last == 0 ) {
mod.sm_op = LDAP_MOD_ADD;
mod.sm_desc = (*ap)->a_desc;
mod.sm_type = mod.sm_desc->ad_cname;
+ mod.sm_numvals = (*tap)->a_numvals;
mod.sm_values = (*tap)->a_vals;
- mod.sm_nvalues = (*tap)->a_nvals;
+ if ( (*tap)->a_nvals != (*tap)->a_vals ) {
+ mod.sm_nvalues = (*tap)->a_nvals;
+ }
(void)modify_add_values( &e, &mod,
/* permissive */ 1,
fname, lineno, argv[ 1 ] );
return 1;
}
+
} else if ( strcasecmp( argv[0], "normalize-mapped-attrs" ) == 0 ) {
if ( argc !=2 ) {
fprintf( stderr,