fix ITS#2362 and other leaks/unhandled massaged DN memory

This commit is contained in:
Pierangelo Masarati 2003-03-11 18:09:38 +00:00
parent 72b6f82cc4
commit fc87692576
3 changed files with 16 additions and 12 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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 */
}