]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#10448 slapo-syncprov: plug leak in syncprov_parseCtrl
authorKang Yang <kangyang126@gmail.com>
Fri, 6 Feb 2026 02:53:52 +0000 (02:53 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 6 Feb 2026 19:40:57 +0000 (19:40 +0000)
servers/slapd/overlays/syncprov.c

index faac81bc0b90164b7df76952b67fa8dfe6702a5b..74d85b21178c1b0a634f07db2f94fac428302982 100644 (file)
@@ -4250,6 +4250,26 @@ syncprov_db_destroy(
        return 0;
 }
 
+static int
+syncprov_ctrl_cleanup( Operation *op, SlapReply *rs )
+{
+       if ( op->o_controls[slap_cids.sc_LDAPsync] ) {
+               sync_control *sr = op->o_controls[slap_cids.sc_LDAPsync];
+               op->o_controls[slap_cids.sc_LDAPsync] = NULL;
+               if ( sr->sr_state.ctxcsn ) {
+                        ber_bvarray_free_x( sr->sr_state.ctxcsn, op->o_tmpmemctx );
+               }
+               if ( sr->sr_state.sids ) {
+                        op->o_tmpfree( sr->sr_state.sids, op->o_tmpmemctx );
+               }
+               if ( sr->sr_state.octet_str.bv_val ) {
+                        op->o_tmpfree( sr->sr_state.octet_str.bv_val, op->o_tmpmemctx );
+               }
+               op->o_tmpfree( sr, op->o_tmpmemctx );
+       }
+       return slap_freeself_cb( op, rs );
+}
+
 static int syncprov_parseCtrl (
        Operation *op,
        SlapReply *rs,
@@ -4357,6 +4377,13 @@ static int syncprov_parseCtrl (
 
        op->o_sync_mode |= mode;        /* o_sync_mode shares o_sync */
 
+       {
+               slap_callback *cb = op->o_tmpcalloc( 1, sizeof(slap_callback), op->o_tmpmemctx );
+               cb->sc_cleanup = syncprov_ctrl_cleanup;
+               cb->sc_next = op->o_callback;
+               op->o_callback = cb;
+       }
+
        return LDAP_SUCCESS;
 }