]> git.sur5r.net Git - openldap/commitdiff
fix ITS#2362 and other leaks/unhandled massaged DN memory
authorPierangelo Masarati <ando@openldap.org>
Tue, 11 Mar 2003 18:09:38 +0000 (18:09 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 11 Mar 2003 18:09:38 +0000 (18:09 +0000)
servers/slapd/back-ldap/extended.c
servers/slapd/back-ldap/modify.c
servers/slapd/back-ldap/search.c

index 47a1f1b6c5a16b31725787bac8d2f850831e1564..a2697296fc7f85862f5d19cdb487ae778ae32fbd 100644 (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);
index 1db0e88d00107a702c03375873d3f180f246d93b..4e947bfbd72cc81325129a89a2539b9ce4f1f3c7 100644 (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);
        }
index 07e0f30a95d1214706e4684f4aad6d403e2026cf..d0b065b5f34d4ac65280af7335161bcb3fe071e3 100644 (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 */
                        }