From: Pierangelo Masarati Date: Tue, 22 Jun 2010 23:10:48 +0000 (+0000) Subject: don't risk leaving around client library error codes X-Git-Tag: MIGRATION_CVS2GIT~568 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1242443553fed676d868528aa6f257e358f15230;p=openldap don't risk leaving around client library error codes --- diff --git a/servers/slapd/back-ldap/bind.c b/servers/slapd/back-ldap/bind.c index a2f3751fae..1862022ab1 100644 --- a/servers/slapd/back-ldap/bind.c +++ b/servers/slapd/back-ldap/bind.c @@ -584,12 +584,13 @@ retry:; rc = ldap_parse_extended_result( ld, res, NULL, &data, 0 ); if ( rc == LDAP_SUCCESS ) { - int err; - rc = ldap_parse_result( ld, res, &err, + SlapReply rs; + rc = ldap_parse_result( ld, res, &rs.sr_err, NULL, NULL, NULL, NULL, 1 ); - if ( rc == LDAP_SUCCESS ) { - rc = err; + if ( rc != LDAP_SUCCESS ) { + rs.sr_err = rc; } + rc = slap_map_api2result( &rs ); res = NULL; /* FIXME: in case a referral @@ -1804,10 +1805,12 @@ retry:; rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err, &match, &text, &refs, &ctrls, 1 ); - rs->sr_text = text; - if ( rc != LDAP_SUCCESS ) { + if ( rc == LDAP_SUCCESS ) { + rs->sr_text = text; + } else { rs->sr_err = rc; } + rs->sr_err = slap_map_api2result( rs ); /* RFC 4511: referrals can only appear * if result code is LDAP_REFERRAL */ @@ -1901,14 +1904,14 @@ retry:; ber_memvfree( (void **)refs ); } - /* match should not be possible with a successful bind */ - if ( match ) { - if ( rs->sr_matched != match ) { - free( (char *)rs->sr_matched ); - } - rs->sr_matched = NULL; - ldap_memfree( match ); + /* match should not be possible with a successful bind */ + if ( match ) { + if ( rs->sr_matched != match ) { + free( (char *)rs->sr_matched ); } + rs->sr_matched = NULL; + ldap_memfree( match ); + } if ( ctrls != NULL ) { if ( op->o_tag == LDAP_REQ_BIND && rs->sr_err == LDAP_SUCCESS ) { diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index f168a87a5d..95ecdbd343 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -488,14 +488,15 @@ retry: rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err, &match.bv_val, &err, &references, &rs->sr_ctrls, 1 ); - if ( rc != LDAP_SUCCESS ) { + if ( rc == LDAP_SUCCESS ) { + if ( err ) { + rs->sr_text = err; + freetext = 1; + } + } else { rs->sr_err = rc; } rs->sr_err = slap_map_api2result( rs ); - if ( err ) { - rs->sr_text = err; - freetext = 1; - } /* RFC 4511: referrals can only appear * if result code is LDAP_REFERRAL */