]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9866 delta-sync: fix DN leak on Adds
authorHoward Chu <hyc@openldap.org>
Thu, 16 Jun 2022 20:32:07 +0000 (21:32 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Thu, 23 Jun 2022 18:47:25 +0000 (18:47 +0000)
servers/slapd/syncrepl.c

index 6ed55801778f21b3d77fd6b9d117eefa48a62e31..52e67e48faab095474b99198439b0cabab18860a 100644 (file)
@@ -3107,10 +3107,8 @@ syncrepl_message_to_op(
                                ch_free( bvals );
                                goto done;
                        }
-                       ber_dupbv( &op->o_req_dn, &dn );
-                       ber_dupbv( &op->o_req_ndn, &ndn );
-                       slap_sl_free( ndn.bv_val, op->o_tmpmemctx );
-                       slap_sl_free( dn.bv_val, op->o_tmpmemctx );
+                       op->o_req_dn = dn;
+                       op->o_req_ndn = ndn;
                        freeReqDn = 1;
                } else if ( !ber_bvstrcasecmp( &bv, &ls->ls_req ) ) {
                        int i = verb_to_mask( bvals[0].bv_val, modops );
@@ -3220,9 +3218,8 @@ syncrepl_message_to_op(
                if ( op->o_tag == LDAP_REQ_ADD ) {
                        Entry *e = entry_alloc();
                        op->ora_e = e;
-                       op->ora_e->e_name = op->o_req_dn;
-                       op->ora_e->e_nname = op->o_req_ndn;
-                       freeReqDn = 0;
+                       ber_dupbv( &op->ora_e->e_name, &op->o_req_dn );
+                       ber_dupbv( &op->ora_e->e_nname, &op->o_req_ndn );
                        rc = slap_mods2entry( modlist, &op->ora_e, 1, 0, &text, txtbuf, textlen);
                        if( rc != LDAP_SUCCESS ) {
                                Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_op: %s "
@@ -3353,8 +3350,8 @@ done:
                }
        }
        if ( freeReqDn ) {
-               ch_free( op->o_req_ndn.bv_val );
-               ch_free( op->o_req_dn.bv_val );
+               op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
+               op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
        }
        ber_free( ber, 0 );
        return rc;