From 671b02f7485c16579585fd8ffc2f2f0ba9c1b240 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Wed, 29 Jun 2005 12:28:40 +0000 Subject: [PATCH] more on ITS#3808 --- libraries/libldap/os-ip.c | 1 + servers/slapd/back-ldap/bind.c | 23 ++++++++++++++++------- servers/slapd/back-ldap/search.c | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index 407f5ebad2..7715044f14 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -903,6 +903,7 @@ ldap_int_select( LDAP *ld, struct timeval *timeout ) #endif sip = (struct selectinfo *)ld->ld_selectinfo; + assert( sip != NULL ); #ifdef HAVE_POLL { diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index b817be965a..13fba4a4b0 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -101,17 +101,25 @@ done:; /* must re-insert if local DN changed as result of bind */ if ( lc->lc_bound && !dn_match( &op->o_req_ndn, &lc->lc_local_ndn ) ) { - int lerr; + struct ldapconn *tmplc; + int lerr; ldap_pvt_thread_mutex_lock( &li->conn_mutex ); - lc = avl_delete( &li->conntree, (caddr_t)lc, + tmplc = avl_delete( &li->conntree, (caddr_t)lc, ldap_back_conn_cmp ); - if ( !BER_BVISNULL( &lc->lc_local_ndn ) ) { - ch_free( lc->lc_local_ndn.bv_val ); + if ( tmplc != NULL ) { + if ( !BER_BVISNULL( &lc->lc_local_ndn ) ) { + ch_free( lc->lc_local_ndn.bv_val ); + } + ber_dupbv( &lc->lc_local_ndn, &op->o_req_ndn ); + lerr = avl_insert( &li->conntree, (caddr_t)lc, + ldap_back_conn_cmp, ldap_back_conn_dup ); + + } else { + /* something BAD happened */ + lerr = -1; + rc = LDAP_OTHER; } - ber_dupbv( &lc->lc_local_ndn, &op->o_req_ndn ); - lerr = avl_insert( &li->conntree, (caddr_t)lc, - ldap_back_conn_cmp, ldap_back_conn_dup ); ldap_pvt_thread_mutex_unlock( &li->conn_mutex ); if ( lerr == -1 ) { ldap_back_conn_free( lc ); @@ -444,6 +452,7 @@ ldap_back_getconn( Operation *op, SlapReply *rs, ldap_back_send_t sendok ) /* Err could be -1 in case a duplicate ldapconn is inserted */ if ( rs->sr_err != 0 ) { ldap_back_conn_free( lc ); + rs->sr_err = LDAP_OTHER; if ( op->o_conn && ( sendok & LDAP_BACK_SENDERR ) ) { send_ldap_error( op, rs, LDAP_OTHER, "internal server error" ); diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 84b0902f9a..d7fb4a8afb 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -286,7 +286,7 @@ fail:; e = ldap_first_entry( lc->lc_ld, res ); rc = ldap_build_entry( op, e, &ent, &bdn ); - if ( rc == LDAP_SUCCESS ) { + if ( rc == LDAP_SUCCESS ) { rs->sr_entry = &ent; rs->sr_attrs = op->ors_attrs; rs->sr_operational_attrs = NULL; -- 2.39.5