]> git.sur5r.net Git - openldap/commitdiff
import fix to ITS#5124
authorPierangelo Masarati <ando@openldap.org>
Fri, 7 Sep 2007 09:40:11 +0000 (09:40 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 7 Sep 2007 09:40:11 +0000 (09:40 +0000)
CHANGES
servers/slapd/overlays/rwm.c

diff --git a/CHANGES b/CHANGES
index 32790775ed25018d91e935a9f6bc1871b51fa578..ffe27ba5f22452e85969b991246f2c29c4e961d9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,7 @@ OpenLDAP 2.3.39 Engineering
        Fixed slapd-bdb DB_CONFIG conversion bug (ITS#5118)
        Fixed slapd-sql concurrency issue (ITS#5095)
        Fixed slapo-pcache and -rwm interaction fix (ITS#4991) 
+       Fixed slapo-rwm modlist handling (ITS#5124)
        Fixed liblber Windows x64 portability (ITS#5105)
        Fixed libldap ppolicy control creation (ITS#5103)
        Documentation
index b836b5da1c275f8387e7206a41009115b9c0dfa5..b52d39a3754832b23cf6d833389d7255cb14a0e7 100644 (file)
@@ -516,6 +516,34 @@ rwm_op_delete( Operation *op, SlapReply *rs )
        return SLAP_CB_CONTINUE;
 }
 
+/* imported from HEAD */
+static int
+ber_bvarray_dup_x( BerVarray *dst, BerVarray src, void *ctx )
+{
+       int i, j;
+       BerVarray new;
+
+       if ( !src ) {
+               *dst = NULL;
+               return 0;
+       }
+
+       for (i=0; !BER_BVISNULL( &src[i] ); i++) ;
+       new = ber_memalloc_x(( i+1 ) * sizeof(BerValue), ctx );
+       if ( !new )
+               return -1;
+       for (j=0; j<i; j++) {
+               ber_dupbv_x( &new[j], &src[j], ctx );
+               if ( BER_BVISNULL( &new[j] )) {
+                       ber_bvarray_free_x( new, ctx );
+                       return -1;
+               }
+       }
+       BER_BVZERO( &new[j] );
+       *dst = new;
+       return 0;
+}
+
 static int
 rwm_op_modify( Operation *op, SlapReply *rs )
 {
@@ -544,21 +572,26 @@ rwm_op_modify( Operation *op, SlapReply *rs )
        isupdate = be_shadow_update( op );
        for ( mlp = &op->oq_modify.rs_modlist; *mlp; ) {
                int                     is_oc = 0;
-               Modifications           *ml;
+               Modifications           *ml = *mlp;
                struct ldapmapping      *mapping = NULL;
 
-               /* duplicate the modlist */
-               ml = ch_malloc( sizeof( Modifications ));
-               *ml = **mlp;
-               *mlp = ml;
-
+               /* ml points to a temporary mod until needs duplication */
                if ( ml->sml_desc == slap_schema.si_ad_objectClass 
                                || ml->sml_desc == slap_schema.si_ad_structuralObjectClass )
                {
                        is_oc = 1;
 
-               } else if ( !isupdate && !get_manageDIT( op ) && (*mlp)->sml_desc->ad_type->sat_no_user_mod  )
+               } else if ( !isupdate && !get_manageDIT( op ) && ml->sml_desc->ad_type->sat_no_user_mod  )
                {
+                       ml = ch_malloc( sizeof( Modifications ) );
+                       *ml = **mlp;
+                       if ( (*mlp)->sml_values ) {
+                               ber_bvarray_dup_x( &ml->sml_values, (*mlp)->sml_values, NULL );
+                               if ( (*mlp)->sml_nvalues ) {
+                                       ber_bvarray_dup_x( &ml->sml_nvalues, (*mlp)->sml_nvalues, NULL );
+                               }
+                       }
+                       *mlp = ml;
                        goto next_mod;
 
                } else {
@@ -573,6 +606,11 @@ rwm_op_modify( Operation *op, SlapReply *rs )
                        }
                }
 
+               /* duplicate the modlist */
+               ml = ch_malloc( sizeof( Modifications ));
+               *ml = **mlp;
+               *mlp = ml;
+
                if ( ml->sml_values != NULL ) {
                        int i, num;
                        struct berval *bva;