From: Howard Chu Date: Thu, 9 Apr 2026 15:02:00 +0000 (+0100) Subject: ITS#10492 slapd: fix send_ldap_result abandon/error code munging X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=a73d539730e43e1ddf4f6adee2c2e87243b3fd15;p=thirdparty%2Fopenldap.git ITS#10492 slapd: fix send_ldap_result abandon/error code munging --- diff --git a/servers/slapd/result.c b/servers/slapd/result.c index c9ba815924..0cc1106bcf 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -874,6 +874,19 @@ slap_send_ldap_result( Operation *op, SlapReply *rs ) rs->sr_type = REP_RESULT; + assert( !LDAP_API_ERROR( rs->sr_err ) ); + assert( rs->sr_err != LDAP_PARTIAL_RESULTS ); + + if ( rs->sr_err == LDAP_REFERRAL ) { + if( op->o_domain_scope ) rs->sr_ref = NULL; + + if( rs->sr_ref == NULL ) { + rs->sr_err = LDAP_NO_SUCH_OBJECT; + } else if ( op->o_protocol < LDAP_VERSION3 ) { + rs->sr_err = LDAP_PARTIAL_RESULTS; + } + } + /* Propagate Abandons so that cleanup callbacks can be processed */ if ( rs->sr_err == SLAPD_ABANDON || op->o_abandon ) goto abandon; @@ -890,18 +903,6 @@ slap_send_ldap_result( Operation *op, SlapReply *rs ) "send_ldap_result: referral=\"%s\"\n", rs->sr_ref[0].bv_val ? rs->sr_ref[0].bv_val : "NULL" ); } - assert( !LDAP_API_ERROR( rs->sr_err ) ); - assert( rs->sr_err != LDAP_PARTIAL_RESULTS ); - - if ( rs->sr_err == LDAP_REFERRAL ) { - if( op->o_domain_scope ) rs->sr_ref = NULL; - - if( rs->sr_ref == NULL ) { - rs->sr_err = LDAP_NO_SUCH_OBJECT; - } else if ( op->o_protocol < LDAP_VERSION3 ) { - rs->sr_err = LDAP_PARTIAL_RESULTS; - } - } if ( op->o_protocol < LDAP_VERSION3 ) { tmp = v2ref( rs->sr_ref, rs->sr_text );