]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/translucent.c
ITS#7178 fix uninit'd op->ors_deref
[openldap] / servers / slapd / overlays / translucent.c
index 34b23b6362834e1b3f8a251b5337b190f5657172..4f38b92f226405dc47d4a1b23e75f9ce310daec8 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2004-2009 The OpenLDAP Foundation.
+ * Copyright 2004-2012 The OpenLDAP Foundation.
  * Portions Copyright 2005 Symas Corporation.
  * All rights reserved.
  *
@@ -206,6 +206,7 @@ translucent_cf_gen( ConfigArgs *c )
                        ch_free( (*an)[i].an_name.bv_val );
                        do {
                                (*an)[i] = (*an)[i+1];
+                               i++;
                        } while ( !BER_BVISNULL( &(*an)[i].an_name ));
                }
                return 0;
@@ -628,7 +629,6 @@ static int translucent_pwmod(Operation *op, SlapReply *rs) {
 
        slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
        translucent_info *ov = on->on_bi.bi_private;
-       const struct berval bv_exop_pwmod = BER_BVC(LDAP_EXOP_MODIFY_PASSWD);
        Entry *e = NULL, *re = NULL;
        BackendDB *db;
        int rc = 0;
@@ -723,8 +723,6 @@ static int translucent_pwmod(Operation *op, SlapReply *rs) {
 }
 
 static int translucent_exop(Operation *op, SlapReply *rs) {
-       SlapReply nrs = { REP_RESULT };
-
        slap_overinst *on = (slap_overinst *) op->o_bd->bd_info;
        translucent_info *ov = on->on_bi.bi_private;
        const struct berval bv_exop_pwmod = BER_BVC(LDAP_EXOP_MODIFY_PASSWD);
@@ -816,14 +814,7 @@ static int translucent_search_cb(Operation *op, SlapReply *rs) {
                if ( tc->step & USE_LIST ) {
                        re = tavl_delete( &tc->list, le, entry_dn_cmp );
                        if ( re ) {
-                               if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
-                                       rs->sr_flags ^= REP_ENTRY_MUSTRELEASE;
-                                       overlay_entry_release_ov( op, rs->sr_entry, 0, on );
-                               }
-                               if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) {
-                                       rs->sr_flags ^= REP_ENTRY_MUSTBEFREED;
-                                       entry_free( rs->sr_entry );
-                               }
+                               rs_flush_entry( op, rs, on );
                                rc = test_filter( op, re, tc->orig );
                                if ( rc == LDAP_COMPARE_TRUE ) {
                                        rs->sr_flags |= REP_ENTRY_MUSTBEFREED;
@@ -856,14 +847,7 @@ static int translucent_search_cb(Operation *op, SlapReply *rs) {
                rc = overlay_entry_get_ov(op, &rs->sr_entry->e_nname, NULL, NULL, 0, &le, on);
                if ( rc == LDAP_SUCCESS && le ) {
                        re = entry_dup( rs->sr_entry );
-                       if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
-                               rs->sr_flags ^= REP_ENTRY_MUSTRELEASE;
-                               overlay_entry_release_ov( op, rs->sr_entry, 0, on );
-                       }
-                       if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) {
-                               rs->sr_flags ^= REP_ENTRY_MUSTBEFREED;
-                               entry_free( rs->sr_entry );
-                       }
+                       rs_flush_entry( op, rs, on );
                } else {
                        le = NULL;
                }
@@ -903,14 +887,7 @@ static int translucent_search_cb(Operation *op, SlapReply *rs) {
                }
                /* Dispose of local entry */
                if ( tc->step & LCL_SIDE ) {
-                       if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
-                               rs->sr_flags ^= REP_ENTRY_MUSTRELEASE;
-                               overlay_entry_release_ov( op, rs->sr_entry, 0, on );
-                       }
-                       if ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) {
-                               rs->sr_flags ^= REP_ENTRY_MUSTBEFREED;
-                               entry_free( rs->sr_entry );
-                       }
+                       rs_flush_entry(op, rs, on);
                } else {
                        overlay_entry_release_ov(op, le, 0, on);
                }
@@ -1159,17 +1136,18 @@ static int translucent_search(Operation *op, SlapReply *rs) {
                        av = tavl_end( tc.list, TAVL_DIR_LEFT );
                        while ( av ) {
                                rs->sr_entry = av->avl_data;
-                               rc = test_filter( op, rs->sr_entry, op->ors_filter );
-                               if ( rc == LDAP_COMPARE_TRUE ) {
+                               if ( rc == LDAP_SUCCESS && LDAP_COMPARE_TRUE ==
+                                       test_filter( op, rs->sr_entry, op->ors_filter ))
+                               {
                                        rs->sr_flags = REP_ENTRY_MUSTBEFREED;
                                        rc = send_search_entry( op, rs );
-                                       if ( rc ) break;
                                } else {
                                        entry_free( rs->sr_entry );
                                }
                                av = tavl_next( av, TAVL_DIR_RIGHT );
                        }
                        tavl_free( tc.list, NULL );
+                       rs->sr_flags = 0;
                        rs->sr_entry = NULL;
                }
                send_ldap_result( op, rs );
@@ -1382,6 +1360,7 @@ translucent_db_destroy( BackendDB *be, ConfigReply *cr )
                        backend_stopdown_one( &ov->db );
                }
 
+               ldap_pvt_thread_mutex_destroy( &ov->db.be_pcl_mutex );
                ch_free(ov);
                on->on_bi.bi_private = NULL;
        }