]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/rwm.c
ITS#7178 fix uninit'd op->ors_deref
[openldap] / servers / slapd / overlays / rwm.c
index 9785ae445371d74a74b0bc851b6da1befdee2148..cc6211ed2508d4084d84e088afea42fe18a5471a 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003-2010 The OpenLDAP Foundation.
+ * Copyright 2003-2012 The OpenLDAP Foundation.
  * Portions Copyright 2003 Pierangelo Masarati.
  * All rights reserved.
  *
@@ -1154,7 +1154,7 @@ rwm_extended( Operation *op, SlapReply *rs )
        return SLAP_CB_CONTINUE;
 }
 
-static int
+static void
 rwm_matched( Operation *op, SlapReply *rs )
 {
        slap_overinst           *on = (slap_overinst *) op->o_bd->bd_info;
@@ -1166,7 +1166,7 @@ rwm_matched( Operation *op, SlapReply *rs )
        int                     rc;
 
        if ( rs->sr_matched == NULL ) {
-               return SLAP_CB_CONTINUE;
+               return;
        }
 
        dc.rwmap = rwmap;
@@ -1179,10 +1179,8 @@ rwm_matched( Operation *op, SlapReply *rs )
        if ( rc != LDAP_SUCCESS ) {
                rs->sr_err = rc;
                rs->sr_text = "Rewrite error";
-               return 1;
-       }
 
-       if ( mdn.bv_val != dn.bv_val ) {
+       } else if ( mdn.bv_val != dn.bv_val ) {
                if ( rs->sr_flags & REP_MATCHED_MUSTBEFREED ) {
                        ch_free( (void *)rs->sr_matched );
 
@@ -1191,8 +1189,6 @@ rwm_matched( Operation *op, SlapReply *rs )
                }
                rs->sr_matched = mdn.bv_val;
        }
-       
-       return SLAP_CB_CONTINUE;
 }
 
 static int
@@ -1281,7 +1277,13 @@ rwm_attrs( Operation *op, SlapReply *rs, Attribute** a_first, int stripEntryDN )
                                                                NULL );
 
                                                        if ( rc != LDAP_SUCCESS ) {
-                                                               BER_BVZERO( &(*ap)->a_nvals[i] );
+                                                               /* FIXME: this is wrong, putting a non-normalized value
+                                                                * into nvals. But when a proxy sends us bogus data,
+                                                                * we still need to give it to the client, even if it
+                                                                * violates the syntax. I.e., we don't want to silently
+                                                                * drop things and trigger an apparent data loss.
+                                                                */
+                                                               ber_dupbv( &(*ap)->a_nvals[i], &(*ap)->a_vals[i] );
                                                        }
                                                }
                                                BER_BVZERO( &(*ap)->a_nvals[i] );
@@ -1761,20 +1763,18 @@ rwm_response( Operation *op, SlapReply *rs )
                        dc.rs = NULL; 
                        dc.ctx = "referralDN";
                        rc = rwm_referral_result_rewrite( &dc, rs->sr_ref );
+                       /* FIXME: impossible, so far */
                        if ( rc != LDAP_SUCCESS ) {
-                               rc = 1;
+                               rs->sr_err = rc;
                                break;
                        }
                }
-               rc = rwm_matched( op, rs );
-               break;
 
-       default:
-               rc = SLAP_CB_CONTINUE;
+               rwm_matched( op, rs );
                break;
        }
 
-       return rc;
+       return SLAP_CB_CONTINUE;
 }
 
 static int