From: Pierangelo Masarati Date: Tue, 11 Mar 2003 18:09:38 +0000 (+0000) Subject: fix ITS#2362 and other leaks/unhandled massaged DN memory X-Git-Tag: NO_SLAP_OP_BLOCKS~144 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fc876925766e2fb987845c853dba088ac876a5f2;p=openldap fix ITS#2362 and other leaks/unhandled massaged DN memory --- diff --git a/servers/slapd/back-ldap/extended.c b/servers/slapd/back-ldap/extended.c index 47a1f1b6c5..a2697296fc 100644 --- a/servers/slapd/back-ldap/extended.c +++ b/servers/slapd/back-ldap/extended.c @@ -139,10 +139,11 @@ ldap_back_exop_passwd( rc = ldap_passwd(lc->ld, id.bv_len ? &mdn : NULL, old.bv_len ? &old : NULL, new.bv_len ? &new : NULL, op->o_ctrls, NULL, &msgid); -#ifdef ENABLE_REWRITE - if (mdn.bv_val != dn.bv_val) -#endif + + if (mdn.bv_val != dn.bv_val) { free(mdn.bv_val); + } + if (rc == LDAP_SUCCESS) { if (ldap_result(lc->ld, msgid, 1, NULL, &res) == -1) { ldap_get_option(lc->ld, LDAP_OPT_ERROR_NUMBER, &rc); diff --git a/servers/slapd/back-ldap/modify.c b/servers/slapd/back-ldap/modify.c index 1db0e88d00..4e947bfbd7 100644 --- a/servers/slapd/back-ldap/modify.c +++ b/servers/slapd/back-ldap/modify.c @@ -162,13 +162,9 @@ ldap_back_modify( rc = ldap_modify_ext( lc->ld, mdn.bv_val, modv, op->o_ctrls, NULL, &msgid ); cleanup:; -#ifdef ENABLE_REWRITE if ( mdn.bv_val != dn->bv_val ) { -#endif /* ENABLE_REWRITE */ free( mdn.bv_val ); -#ifdef ENABLE_REWRITE } -#endif /* ENABLE_REWRITE */ for (i=0; modv[i]; i++) { ch_free(modv[i]->mod_bvalues); } diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 07e0f30a95..d0b065b5f3 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -76,9 +76,7 @@ ldap_back_search( char *match = NULL, *err = NULL; char **mapped_attrs = NULL; struct berval mbase; -#ifdef ENABLE_REWRITE char *mmatch = NULL; -#endif /* ENABLE_REWRITE */ struct berval mfilter = { 0, NULL }; struct slap_limits_set *limit = NULL; int isroot = 0; @@ -345,20 +343,26 @@ fail:; mmatch, err, v2refs, NULL, count ); #else /* !ENABLE_REWRITE */ + if ( match != NULL ) { + struct berval dn, mdn; + + ber_str2bv(match, 0, 0, &dn); + ldap_back_dn_massage(li, &dn, &mdn, 0, 0); + mmatch = mdn.bv_val; + } + if ( v2refs ) { sres = LDAP_REFERRAL; } send_search_result( conn, op, sres, - match, err, v2refs, NULL, count ); + mmatch, err, v2refs, NULL, count ); #endif /* !ENABLE_REWRITE */ finish:; if ( match ) { -#ifdef ENABLE_REWRITE if ( mmatch != match ) { free( mmatch ); } -#endif /* ENABLE_REWRITE */ LDAP_FREE(match); } if ( err ) { @@ -582,6 +586,9 @@ ldap_send_entry( } #else /* !ENABLE_REWRITE */ ldap_back_dn_massage( li, bv, &newval, 0, 0 ); + if ( bv->bv_val != newval.bv_val ) { + LBER_FREE( bv->bv_val ); + } *bv = newval; #endif /* !ENABLE_REWRITE */ }