]> git.sur5r.net Git - openldap/commitdiff
slap_mods2entry() should not zero pointers into the modifications
authorLuke Howard <lukeh@openldap.org>
Mon, 1 Aug 2005 02:16:02 +0000 (02:16 +0000)
committerLuke Howard <lukeh@openldap.org>
Mon, 1 Aug 2005 02:16:02 +0000 (02:16 +0000)
list because checking is performed on these, rather than the entry.

slap_mods_free() now takes an extra argument indicating whether to
free the values or not.

15 files changed:
servers/slapd/add.c
servers/slapd/back-bdb/modrdn.c
servers/slapd/back-ldbm/modrdn.c
servers/slapd/modify.c
servers/slapd/mods.c
servers/slapd/overlays/pcache.c
servers/slapd/overlays/ppolicy.c
servers/slapd/overlays/refint.c
servers/slapd/overlays/translucent.c
servers/slapd/passwd.c
servers/slapd/proto-slap.h
servers/slapd/sasl.c
servers/slapd/slapi/slapi_ops.c
servers/slapd/slapi/slapi_utils.c
servers/slapd/syncrepl.c

index d0fcef1dbed7ffbbc13ba20799f2b8e763080884..1c23986c611d639fa36bdbbebfdb42936c840650 100644 (file)
@@ -40,7 +40,7 @@ do_add( Operation *op, SlapReply *rs )
        struct berval   dn = BER_BVNULL;
        ber_len_t       len;
        ber_tag_t       tag;
-       Modifications   *modlist = NULL;
+       Modifications   *modlist = NULL, *next;
        Modifications   **modtail = &modlist;
        Modifications   tmp;
        char            textbuf[ SLAP_TEXT_BUFLEN ];
@@ -195,8 +195,9 @@ done:;
        slap_graduate_commit_csn( op );
 
        if ( modlist != NULL ) {
-               slap_mods_free( modlist );
+               slap_mods_free( modlist, 0 );
        }
+
        if ( op->ora_e != NULL ) {
                entry_free( op->ora_e );
        }
@@ -450,8 +451,6 @@ slap_mods2entry(
                        } else {
                                AC_MEMCPY( &attr->a_vals[i], mods->sml_values,
                                        sizeof( struct berval ) * j );
-                               ch_free( mods->sml_values );
-                               mods->sml_values = NULL;
                        }
 
                        if( mods->sml_nvalues ) {
@@ -465,8 +464,6 @@ slap_mods2entry(
                                } else {
                                        AC_MEMCPY( &attr->a_nvals[i], mods->sml_nvalues,
                                                sizeof( struct berval ) * j );
-                                       ch_free( mods->sml_nvalues );
-                                       mods->sml_nvalues = NULL;
                                }
                        } else {
                                attr->a_nvals = attr->a_vals;
@@ -520,7 +517,6 @@ slap_mods2entry(
 
                /* move ad to attr structure */
                attr->a_desc = mods->sml_desc;
-               if ( !dup ) mods->sml_desc = NULL;
 
                /* move values to attr structure */
                /*      should check for duplicates */
@@ -534,7 +530,6 @@ slap_mods2entry(
                        BER_BVZERO( &attr->a_vals[i] );
                } else {
                        attr->a_vals = mods->sml_values;
-                       mods->sml_values = NULL;
                }
 
                if ( mods->sml_nvalues ) {
@@ -548,7 +543,6 @@ slap_mods2entry(
                                BER_BVZERO( &attr->a_nvals[i] );
                        } else {
                                attr->a_nvals = mods->sml_nvalues;
-                               mods->sml_nvalues = NULL;
                        }
                } else {
                        attr->a_nvals = attr->a_vals;
index 458d17e3d5cdc84785b97f0400f3b5c136e1a540..0a6b8d7fd2c7281d2e2f6bb2638e21c631610fad 100644 (file)
@@ -874,7 +874,7 @@ done:
                        if ( mod->sml_nvalues ) free( mod->sml_nvalues[0].bv_val );
                        free( mod );
                }
-               slap_mods_free( mod );
+               slap_mods_free( mod, 1 );
        }
 
        /* LDAP v3 Support */
index eb81387ba82de62b808e7f9f07552ae7fef6b0d9..c8ef1e5446379e24ead8ebfcf2f54773354fcc16 100644 (file)
@@ -529,7 +529,7 @@ return_results:
                        tmp = mod->sml_next;
                        free( mod );
                }
-               slap_mods_free( mod );
+               slap_mods_free( mod, 1 );
        }
 
        /* LDAP v3 Support */
index 12ac2da1fbb5ad1172dacb196d166c3f64198792..becbd71310ac5e33408cafe88cb74644c3ad78d0 100644 (file)
@@ -204,7 +204,7 @@ cleanup:
 
        op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
        op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
-       if ( op->orm_modlist != NULL ) slap_mods_free( op->orm_modlist );
+       if ( op->orm_modlist != NULL ) slap_mods_free( op->orm_modlist, 1 );
 
        return rs->sr_err;
 }
index 7ebba1b3e6a1cbac156b70b9e90974fc2665b122..4be7849f2da30c4e0807915458bd6300245684f9 100644 (file)
@@ -432,14 +432,16 @@ slap_mod_free(
 
 void
 slap_mods_free(
-    Modifications      *ml )
+    Modifications      *ml,
+    int                        freevals )
 {
        Modifications *next;
 
        for ( ; ml != NULL; ml = next ) {
                next = ml->sml_next;
 
-               slap_mod_free( &ml->sml_mod, 0 );
+               if ( freevals )
+                       slap_mod_free( &ml->sml_mod, 0 );
                free( ml );
        }
 }
index 5d2d1247e2a914593fb2606462baac76132af1f4..14a3c25bf63e27da52bab688c369ac5e268806e9 100644 (file)
@@ -186,7 +186,7 @@ merge_entry(
                        op->o_tag = LDAP_REQ_MODIFY;
                        op->orm_modlist = modlist;
                        op->o_bd->be_modify( op, &sreply );
-                       slap_mods_free( modlist );
+                       slap_mods_free( modlist, 1 );
                } else if ( rc == LDAP_REFERRAL ||
                                        rc == LDAP_NO_SUCH_OBJECT ) {
                        syncrepl_add_glue( op, e );
index bbb208161afd937dc8b752234c9360ebda6fdd6e..64daabd22c6ced03217d8f66c3820ed90e474d16 100644 (file)
@@ -919,7 +919,7 @@ locked:
                op2.o_ndn = op->o_bd->be_rootndn;
                op2.o_bd->bd_info = (BackendInfo *)on->on_info;
                rc = op->o_bd->be_modify( &op2, &r2 );
-               slap_mods_free( mod );
+               slap_mods_free( mod, 1 );
        }
 
        if ( ppb->send_ctrl ) {
index b6e175fa72e3d9952504921dd33b1e89d8a3a49b..41e1cbc9cf0739e4f49a38ceff0836545a565879 100644 (file)
@@ -653,7 +653,7 @@ done:
        for(dp = dd.mods; dp; dp = dd.mods) {
                dd.mods = dp->next;
                ch_free(dp->dn.bv_val);
-               slap_mods_free(dp->mm);
+               slap_mods_free(dp->mm, 1);
        }
        dd.mods = NULL;
 
index 72b57e76d595b0b94b04058c1fa6445e223d0189..85724d5f507f27f1c1b64a58da4ef55e2df0996a 100644 (file)
@@ -290,7 +290,7 @@ static int translucent_modify(Operation *op, SlapReply *rs) {
                                mm = m;
                                m = m->sml_next;
                                mm->sml_next = NULL;            /* hack */
-                               slap_mods_free(mm);
+                               slap_mods_free(mm, 1);
                                if(m) continue;
                        }
                        m->sml_op = LDAP_MOD_ADD;
index 82acabab4a343a77d5b41ed08f82a2d431b662d2..738d9add84f0b5ec9970f8ee28d61cb549eced88 100644 (file)
@@ -243,7 +243,7 @@ int passwd_extop(
                op->o_tag = LDAP_REQ_EXTENDED;
                op->o_callback = sc;
        }
-       slap_mods_free( qpw->rs_mods );
+       slap_mods_free( qpw->rs_mods, 1 );
        if ( rsp ) {
                free( qpw->rs_new.bv_val );
        }
index 77eea618ac519b3684efc01a6ee7141bafb8a877..660dbdcd51438fcebd15576234520609c3fdda12 100644 (file)
@@ -1006,7 +1006,7 @@ LDAP_SLAPD_F( int ) modify_increment_values( Entry *e,
        const char **text, char *textbuf, size_t textlen );
 
 LDAP_SLAPD_F( void ) slap_mod_free( Modification *mod, int freeit );
-LDAP_SLAPD_F( void ) slap_mods_free( Modifications *mods );
+LDAP_SLAPD_F( void ) slap_mods_free( Modifications *mods, int freevals );
 LDAP_SLAPD_F( void ) slap_modlist_free( LDAPModList *ml );
 
 /*
index 385e912c6c5c26fd901c1c75a78ae4395dcb26c8..e92780132f496f81f7342652a0525b062a263328 100644 (file)
@@ -439,7 +439,7 @@ slap_auxprop_store(
                        }
                }
        }
-       slap_mods_free( modlist );
+       slap_mods_free( modlist, 1 );
        return rc != LDAP_SUCCESS ? SASL_FAIL : SASL_OK;
 }
 #endif /* SASL_VERSION_FULL >= 2.1.16 */
index d57f3fc65121ee2267ee4ab3cb52d841ed6a7cd7..b5f1c48b5dbde1eee47c80599cd3a34ade0a11af 100644 (file)
@@ -344,10 +344,10 @@ slapi_int_connection_done_pb( Slapi_PBlock *pb )
                }
                break;
        case LDAP_REQ_ADD:
-               slap_mods_free( op->ora_modlist );
+               slap_mods_free( op->ora_modlist, 1 );
                break;
        case LDAP_REQ_MODIFY:
-               slap_mods_free( op->orm_modlist );
+               slap_mods_free( op->orm_modlist, 1 );
                break;
        case LDAP_REQ_SEARCH:
                if ( op->ors_attrs != NULL ) {
@@ -498,7 +498,7 @@ cleanup:
        }
        if ( entry_orig != NULL ) {
                pb->pb_op->ora_e = entry_orig;
-               slap_mods_free( pb->pb_op->ora_modlist );
+               slap_mods_free( pb->pb_op->ora_modlist, 1 );
                pb->pb_op->ora_modlist = NULL;
        }
 
index 46173593185903a6081a93acdc7e8a4d35ea9382..25f82e872cae7ae5e04eece0313c618e921531d6 100644 (file)
@@ -2730,7 +2730,7 @@ LDAPMod **slapi_int_modifications2ldapmods(
 
        mods[i] = NULL;
 
-       slap_mods_free( modlist );
+       slap_mods_free( modlist, 1 );
        *pmodlist = NULL;
 
        return mods;
index 79e17094fbc8c0115527c758a83e552fb79f0561..087a7cf46f93716343fc2ab267356a2ce705c3f3 100644 (file)
@@ -629,7 +629,7 @@ do_syncrep2(
                                }
                                ldap_controls_free( rctrls );
                                if ( modlist ) {
-                                       slap_mods_free( modlist );
+                                       slap_mods_free( modlist, 1 );
                                }
                                if ( rc_efree && entry ) {
                                        entry_free( entry );