]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/rwm.c
check for ee == NULL
[openldap] / servers / slapd / overlays / rwm.c
index 88e7146b7990c0248a724dbc59cbc30c4529eaa8..ed9fbfa9bb20377093a0a18dfda2fcd3403357d1 100644 (file)
@@ -226,9 +226,7 @@ rwm_op_add( Operation *op, SlapReply *rs )
                {
                        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;
 
@@ -245,6 +243,7 @@ rwm_op_add( Operation *op, SlapReply *rs )
                                                        (*ap)->a_vals[ j ] = (*ap)->a_vals[ last ];
                                                }
                                                BER_BVZERO( &(*ap)->a_vals[ last ] );
+                                               (*ap)->a_numvals--;
                                                last--;
                                                j--;
                                        }
@@ -845,8 +844,11 @@ rwm_exop_passwd( Operation *op, SlapReply *rs )
        }
 
        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;
@@ -1054,9 +1056,8 @@ rwm_attrs( Operation *op, SlapReply *rs, Attribute** a_first, int stripEntryDN )
                                        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) );
@@ -1105,8 +1106,7 @@ rwm_attrs( Operation *op, SlapReply *rs, Attribute** a_first, int stripEntryDN )
                }
 
                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 ) {
@@ -1225,6 +1225,7 @@ cleanup_attr:;
                                        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;