From: Pierangelo Masarati Date: Sat, 6 Mar 2004 15:01:16 +0000 (+0000) Subject: initial round of fixes related to ITS#2986 X-Git-Tag: OPENLDAP_REL_ENG_2_2_BP~357 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=abf2df7a1103dd751607b2dbf8ab6bed4d9a8726;p=openldap initial round of fixes related to ITS#2986 --- diff --git a/servers/slapd/back-meta/bind.c b/servers/slapd/back-meta/bind.c index c3736c47e9..596386edb6 100644 --- a/servers/slapd/back-meta/bind.c +++ b/servers/slapd/back-meta/bind.c @@ -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; diff --git a/servers/slapd/back-meta/candidates.c b/servers/slapd/back-meta/candidates.c index 6565e715ec..df2e87cefd 100644 --- a/servers/slapd/back-meta/candidates.c +++ b/servers/slapd/back-meta/candidates.c @@ -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; } diff --git a/servers/slapd/back-meta/conn.c b/servers/slapd/back-meta/conn.c index b915a9cf11..8af403d2ab 100644 --- a/servers/slapd/back-meta/conn.c +++ b/servers/slapd/back-meta/conn.c @@ -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 { diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index 8f38adaf4a..bc3e3e6ec3 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -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 );