]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#10492 slapd: fix send_ldap_result abandon/error code munging
authorHoward Chu <hyc@openldap.org>
Thu, 9 Apr 2026 15:02:00 +0000 (16:02 +0100)
committerHoward Chu <hyc@openldap.org>
Thu, 9 Apr 2026 15:02:00 +0000 (16:02 +0100)
servers/slapd/result.c

index c9ba815924033c41fa1a63856d041b5a97b6a80a..0cc1106bcf5b7c461bcda37d7a8988c3b93f2616 100644 (file)
@@ -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 );