From 5509c209618046e84ae13ab1dd86a56459b060b0 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Thu, 1 Feb 2007 21:58:48 +0000 Subject: [PATCH] keep SlapReply clean (ITS#4828) --- servers/slapd/back-ldap/chain.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/servers/slapd/back-ldap/chain.c b/servers/slapd/back-ldap/chain.c index ca42a146d4..3bf88376c4 100644 --- a/servers/slapd/back-ldap/chain.c +++ b/servers/slapd/back-ldap/chain.c @@ -414,6 +414,7 @@ ldap_chain_op( li.li_bvuri = bvuri; first_rc = -1; for ( ; !BER_BVISNULL( ref ); ref++ ) { + SlapReply rs2 = { 0 }; LDAPURLDesc *srv = NULL; struct berval save_req_dn = op->o_req_dn, save_req_ndn = op->o_req_ndn, @@ -523,7 +524,7 @@ Document: RFC 4511 lb->lb_op_f = op_f; lb->lb_depth = depth + 1; - rc = op_f( op, rs ); + rc = op_f( op, &rs2 ); /* note the first error */ if ( first_rc == -1 ) { @@ -552,9 +553,12 @@ further_cleanup:; } op->o_req_ndn = save_req_ndn; - if ( rc == LDAP_SUCCESS && rs->sr_err == LDAP_SUCCESS ) { + if ( rc == LDAP_SUCCESS && rs2.sr_err == LDAP_SUCCESS ) { + *rs = rs2; break; } + + rc = rs2.sr_err; } #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR @@ -606,6 +610,7 @@ ldap_chain_search( * to be set once for all (correct?) */ li.li_bvuri = bvuri; for ( ; !BER_BVISNULL( &ref[0] ); ref++ ) { + SlapReply rs2 = { 0 }; LDAPURLDesc *srv; struct berval save_req_dn = op->o_req_dn, save_req_ndn = op->o_req_ndn, @@ -702,7 +707,7 @@ ldap_chain_search( /* FIXME: should we also copy filter and scope? * according to RFC3296, no */ - rc = lback->bi_op_search( op, rs ); + rc = lback->bi_op_search( op, &rs2 ); if ( first_rc == -1 ) { first_rc = rc; } @@ -732,11 +737,12 @@ further_cleanup:; } op->o_req_ndn = save_req_ndn; - if ( rc == LDAP_SUCCESS && rs->sr_err == LDAP_SUCCESS ) { + if ( rc == LDAP_SUCCESS && rs2.sr_err == LDAP_SUCCESS ) { + *rs = rs2; break; } - rc = rs->sr_err; + rc = rs2.sr_err; } #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR @@ -772,6 +778,7 @@ ldap_chain_response( Operation *op, SlapReply *rs ) slap_callback *sc = op->o_callback, sc2 = { 0 }; int rc = 0; + char *text = NULL; const char *matched; BerVarray ref; struct berval ndn = op->o_ndn; @@ -827,6 +834,8 @@ ldap_chain_response( Operation *op, SlapReply *rs ) SLAP_DBFLAGS( &db ) &= ~SLAP_DBFLAG_MONITORING; op->o_bd = &db; + text = rs->sr_text; + rs->sr_text = NULL; matched = rs->sr_matched; rs->sr_matched = NULL; ref = rs->sr_ref; @@ -960,6 +969,7 @@ cannot_chain:; rc = SLAP_CB_CONTINUE; rs->sr_err = sr_err; rs->sr_type = sr_type; + rs->sr_text = text; rs->sr_matched = matched; rs->sr_ref = ref; } @@ -978,6 +988,7 @@ cannot_chain:; dont_chain:; rs->sr_err = sr_err; rs->sr_type = sr_type; + rs->sr_text = text; rs->sr_matched = matched; rs->sr_ref = ref; op->o_bd = bd; -- 2.39.5