]> git.sur5r.net Git - openldap/commitdiff
broken hack fix for ITS#6632 (fixed in later rev)
authorQuanah Gibson-Mount <quanah@openldap.org>
Tue, 4 Jan 2011 16:08:32 +0000 (16:08 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Tue, 4 Jan 2011 16:08:32 +0000 (16:08 +0000)
servers/slapd/overlays/rwm.c

index 46c2b739407291b9c4effa9d02f6ea74b0ea3b71..54e58464c7b4e3e77ad47d0921fa7cedabe95001 100644 (file)
@@ -34,6 +34,8 @@ typedef struct rwm_op_state {
        struct berval ro_ndn;
        struct berval r_dn;
        struct berval r_ndn;
+       struct berval rx_dn;
+       struct berval rx_ndn;
        AttributeName *mapped_attrs;
        OpRequest o_request;
 } rwm_op_state;
@@ -52,30 +54,46 @@ rwm_send_entry( Operation *op, SlapReply *rs );
 static void
 rwm_op_rollback( Operation *op, SlapReply *rs, rwm_op_state *ros )
 {
-       if ( !BER_BVISNULL( &ros->ro_dn ) ) {
-               op->o_req_dn = ros->ro_dn;
-       }
-       if ( !BER_BVISNULL( &ros->ro_ndn ) ) {
-               op->o_req_ndn = ros->ro_ndn;
-       }
+       /* in case of successful extended operation cleanup
+        * gets called *after* (ITS#6632); this hack counts
+        * on others to cleanup our o_req_dn/o_req_ndn,
+        * while we cleanup theirs. */
+       if ( ros->r_tag == LDAP_REQ_EXTENDED && rs->sr_err == LDAP_SUCCESS ) {
+               if ( !BER_BVISNULL( &ros->rx_dn ) ) {
+                       ch_free( ros->rx_dn.bv_val );
+               }
+               if ( !BER_BVISNULL( &ros->rx_ndn ) ) {
+                       ch_free( ros->rx_ndn.bv_val );
+               }
 
-       if ( !BER_BVISNULL( &ros->r_dn )
-               && ros->r_dn.bv_val != ros->ro_dn.bv_val )
-       {
-               assert( ros->r_dn.bv_val != ros->r_ndn.bv_val );
-               ch_free( ros->r_dn.bv_val );
-               BER_BVZERO( &ros->r_dn );
-       }
+       } else {
+               if ( !BER_BVISNULL( &ros->ro_dn ) ) {
+                       op->o_req_dn = ros->ro_dn;
+               }
+               if ( !BER_BVISNULL( &ros->ro_ndn ) ) {
+                       op->o_req_ndn = ros->ro_ndn;
+               }
 
-       if ( !BER_BVISNULL( &ros->r_ndn )
-               && ros->r_ndn.bv_val != ros->ro_ndn.bv_val )
-       {
-               ch_free( ros->r_ndn.bv_val );
-               BER_BVZERO( &ros->r_ndn );
+               if ( !BER_BVISNULL( &ros->r_dn )
+                       && ros->r_dn.bv_val != ros->ro_dn.bv_val )
+               {
+                       assert( ros->r_dn.bv_val != ros->r_ndn.bv_val );
+                       ch_free( ros->r_dn.bv_val );
+               }
+
+               if ( !BER_BVISNULL( &ros->r_ndn )
+                       && ros->r_ndn.bv_val != ros->ro_ndn.bv_val )
+               {
+                       ch_free( ros->r_ndn.bv_val );
+               }
        }
 
+       BER_BVZERO( &ros->r_dn );
+       BER_BVZERO( &ros->r_ndn );
        BER_BVZERO( &ros->ro_dn );
        BER_BVZERO( &ros->ro_ndn );
+       BER_BVZERO( &ros->rx_dn );
+       BER_BVZERO( &ros->rx_ndn );
 
        switch( ros->r_tag ) {
        case LDAP_REQ_COMPARE:
@@ -228,6 +246,11 @@ rwm_op_dn_massage( Operation *op, SlapReply *rs, void *cookie,
        assert( BER_BVISNULL( &ros->r_ndn ) );
        ros->r_ndn = ndn;
 
+       if ( ros->r_tag == LDAP_REQ_EXTENDED ) {
+               ros->rx_dn = ros->r_dn;
+               ros->rx_ndn = ros->r_ndn;
+       }
+
        return LDAP_SUCCESS;
 }