From: Ondřej Kuzník Date: Tue, 9 Mar 2021 17:31:01 +0000 (+0000) Subject: ITS#9444 Manage sr_ref/sr_matched flags accordingly X-Git-Tag: OPENLDAP_REL_ENG_2_5_3BETA~3^2~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c8afb036a8137ba07d6a6f9172022b34aa88633;p=thirdparty%2Fopenldap.git ITS#9444 Manage sr_ref/sr_matched flags accordingly send_ldap_response() clears them immediately even if we never attached the data to be freed, so when we reinstate them, the flags are gone and the next send_ldap_response() doesn't consider freeing them. --- diff --git a/servers/slapd/back-ldap/chain.c b/servers/slapd/back-ldap/chain.c index 710fe13671..969adf7fa2 100644 --- a/servers/slapd/back-ldap/chain.c +++ b/servers/slapd/back-ldap/chain.c @@ -383,8 +383,8 @@ retry:; default: /* remember the text before it's freed in ldap_back_op_result */ - if ( lb.lb_text ) { - ber_memfree_x( lb.lb_text, op->o_tmpmemctx ); + if ( lb->lb_text ) { + ber_memfree_x( lb->lb_text, op->o_tmpmemctx ); } lb->lb_text = ber_strdup_x( rs->sr_text, op->o_tmpmemctx ); return rs->sr_err; @@ -971,6 +971,7 @@ ldap_chain_response( Operation *op, SlapReply *rs ) const char *text = NULL; const char *matched; BerVarray ref; + slap_mask_t flags = 0; struct berval ndn = op->o_ndn; int sr_err = rs->sr_err; @@ -1034,6 +1035,9 @@ ldap_chain_response( Operation *op, SlapReply *rs ) ref = rs->sr_ref; rs->sr_ref = NULL; + flags = rs->sr_flags & (REP_MATCHED_MUSTBEFREED | REP_REF_MUSTBEFREED); + rs->sr_flags &= ~flags; + /* we need this to know if back-ldap returned any result */ lb.lb_lc = lc; sc2.sc_next = sc->sc_next; @@ -1169,6 +1173,7 @@ cannot_chain:; rs->sr_text = text; rs->sr_matched = matched; rs->sr_ref = ref; + rs->sr_flags |= flags; } #ifdef LDAP_CONTROL_X_CHAINING_BEHAVIOR break; @@ -1189,6 +1194,8 @@ dont_chain:; rs->sr_text = text; rs->sr_matched = matched; rs->sr_ref = ref; + rs->sr_flags |= flags; + op->o_bd = bd; op->o_callback = sc; op->o_ndn = ndn;