https://bugs.openldap.org/show_bug.cgi?id=10492
Issue ID: 10492 Summary: slapd: send_ldap_result must massage return code before handling abandon Product: OpenLDAP Version: 2.6.13 Hardware: All OS: All Status: UNCONFIRMED Keywords: needs_review Severity: normal Priority: --- Component: slapd Assignee: bugs@openldap.org Reporter: hyc@openldap.org Target Milestone: ---
send_ldap_result checks if rs->sr_err == LDAP_REFERRAL and rs->sr_ref == NULL. In that case, there's no actual referral to send so it changes rs->sr_err to LDAP_NO_SUCH_OBJECT. Later send_ldap_response checks if rs->sr_ref == NULL and asserts if rs->sr_err == LDAP_REFERRAL.
If an op was abandoned, the adjustment in send_ldap_result was being skipped, allowing the assert in send_ldap_response to get triggered. The fix is to move the check for abandon to after the error code adjustment has occurred.