]> git.sur5r.net Git - openldap/commitdiff
initial round of fixes related to ITS#2986
authorPierangelo Masarati <ando@openldap.org>
Sat, 6 Mar 2004 15:01:16 +0000 (15:01 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 6 Mar 2004 15:01:16 +0000 (15:01 +0000)
servers/slapd/back-meta/bind.c
servers/slapd/back-meta/candidates.c
servers/slapd/back-meta/conn.c
servers/slapd/back-meta/search.c

index c3736c47e9e9eac1b16d96a9fbfbd70ed20088a5..596386edb65f42745f2c0390559a5409c4931d2c 100644 (file)
@@ -414,6 +414,7 @@ meta_back_op_result( struct metaconn *lc, Operation *op, SlapReply *rs )
        struct metasingleconn *lsc;
        char *rmsg = NULL;
        char *rmatch = NULL;
+       int     free_rmsg = 0, free_rmatch = 0;
 
        for ( i = 0, lsc = lc->conns; !META_LAST(lsc); ++i, ++lsc ) {
                char *msg = NULL;
@@ -457,9 +458,17 @@ meta_back_op_result( struct metaconn *lc, Operation *op, SlapReply *rs )
                        switch ( rs->sr_err ) {
                        default:
                                rerr = rs->sr_err;
+                               if ( rmsg ) {
+                                       ber_memfree( rmsg );
+                               }
                                rmsg = msg;
+                               free_rmsg = 1;
                                msg = NULL;
+                               if ( rmatch ) {
+                                       ber_memfree( rmatch );
+                               }
                                rmatch = match;
+                               free_rmatch = 1;
                                match = NULL;
                                break;
                        }
@@ -478,6 +487,12 @@ meta_back_op_result( struct metaconn *lc, Operation *op, SlapReply *rs )
        rs->sr_text = rmsg;
        rs->sr_matched = rmatch;
        send_ldap_result( op, rs );
+       if ( free_rmsg ) {
+               ber_memfree( rmsg );
+       }
+       if ( free_rmatch ) {
+               ber_memfree( rmatch );
+       }
        rs->sr_text = NULL;
        rs->sr_matched = NULL;
 
index 6565e715ec51cdb4b67989f690655ab1975d7519..df2e87cefd5aad8ae823bbe1c23d7460fa75c19a 100644 (file)
@@ -204,6 +204,12 @@ meta_clear_one_candidate(
                lsc->bound_dn.bv_len = 0;
        }
 
+       if ( lsc->cred.bv_val != NULL ) {
+               ber_memfree( lsc->cred.bv_val );
+               lsc->cred.bv_val = NULL;
+               lsc->cred.bv_len = 0;
+       }
+
        return 0;
 }
 
index b915a9cf11c26bc35d36047ebdf7cc7e31da93fd..8af403d2ab539491b60e8e5e8388c028f0c85704 100644 (file)
@@ -254,6 +254,11 @@ init_one_conn(
                        return rs->sr_err;
                }
 
+               /* copy the DN idf needed */
+               if ( lsc->bound_dn.bv_val == op->o_conn->c_dn.bv_val ) {
+                       ber_dupbv( &lsc->bound_dn, &op->o_conn->c_dn );
+               }
+
                assert( lsc->bound_dn.bv_val );
 
        } else {
index 8f38adaf4a5a26374e831ff2c617b63db40a0753..bc3e3e6ec3d546ad0b23f574218f1ff8e37ceb32 100644 (file)
@@ -58,7 +58,7 @@ meta_back_search( Operation *op, SlapReply *rs )
        struct metaconn *lc;
        struct metasingleconn *lsc;
        struct timeval  tv = { 0, 0 };
-       LDAPMessage     *res, *e;
+       LDAPMessage     *res = NULL, *e;
        int     rc = 0, *msgid, sres = LDAP_SUCCESS;
        char *err = NULL;
        struct berval match = { 0, NULL }, mmatch = { 0, NULL };
@@ -382,6 +382,11 @@ new_candidate:;
                                        0, &tv, &res );
 
                        if ( rc == 0 ) {
+                               /* timeout exceeded */
+
+                               /* FIXME: res should not need to be freed */
+                               assert( res == NULL );
+
                                continue;
 
                        } else if ( rc == -1 ) {
@@ -393,12 +398,19 @@ new_candidate:;
                                send_ldap_result( op, rs );
                                
                                /* anything else needs be done? */
+
+                               /* FIXME: res should not need to be freed */
+                               assert( res == NULL );
+
                                goto finish;
 
                        } else if ( rc == LDAP_RES_SEARCH_ENTRY ) {
                                e = ldap_first_entry( lsc->ld, res );
                                meta_send_entry( op, rs, lc, i, e );
 
+                               ldap_msgfree( res );
+                               res = NULL;
+
                                /*
                                 * If scope is BASE, we need to jump out
                                 * as soon as one entry is found; if
@@ -412,7 +424,7 @@ new_candidate:;
                                        sres = LDAP_SUCCESS;
                                        break;
                                }
-                               ldap_msgfree( res );
+
                                gotit = 1;
 
                        } else if ( rc == LDAP_RES_SEARCH_REFERENCE ) {
@@ -460,9 +472,14 @@ new_candidate:;
                                        rs->sr_ctrls = NULL;
                                }
 
+                               ldap_msgfree( res );
+                               res = NULL;
+
                        } else {
                                rs->sr_err = ldap_result2error( lsc->ld,
                                                res, 1 );
+                               res = NULL;
+
                                sres = ldap_back_map_result( rs );
                                if ( err != NULL ) {
                                        free( err );