]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9444 Pass original message when chain-return-error is set
authorOndřej Kuzník <ondra@mistotebe.net>
Tue, 9 Mar 2021 17:29:38 +0000 (17:29 +0000)
committerQuanah Gibson-Mount <quanah@openldap.org>
Thu, 18 Mar 2021 15:34:26 +0000 (15:34 +0000)
servers/slapd/back-ldap/chain.c

index a771cd374b3c3cbd232e93d92499debe44a06697..710fe1367139b4a8f814afe1807e809b75788e09 100644 (file)
@@ -119,6 +119,7 @@ typedef struct ldap_chain_cb_t {
        ldap_chain_status_t     lb_status;
        ldap_chain_t            *lb_lc;
        slap_operation_t        lb_op_type;
+       char                    *lb_text;
        int                     lb_depth;
 } ldap_chain_cb_t;
 
@@ -381,6 +382,11 @@ retry:;
                        break;
 
                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 );
+                       }
+                       lb->lb_text = ber_strdup_x( rs->sr_text, op->o_tmpmemctx );
                        return rs->sr_err;
                }
 
@@ -1153,6 +1159,7 @@ cannot_chain:;
 #endif /* LDAP_CONTROL_X_CHAINING_BEHAVIOR */
                        if ( LDAP_CHAIN_RETURN_ERR( lc ) ) {
                                sr_err = rs->sr_err = rc;
+                               rs->sr_text = lb.lb_text;
                                rs->sr_type = sr_type;
 
                        } else {
@@ -1186,6 +1193,13 @@ dont_chain:;
        op->o_callback = sc;
        op->o_ndn = ndn;
 
+       if ( rs->sr_text == lb.lb_text ) {
+               rs->sr_text = NULL;
+       }
+       if ( lb.lb_text ) {
+               ber_memfree_x( lb.lb_text, op->o_tmpmemctx );
+       }
+
        return rc;
 }