From b7b9148c7fef33815e4a5510bccb5604cb7aced5 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 9 Oct 2000 22:11:34 +0000 Subject: [PATCH] Return more appropriate result codes than LDAP_UNAVAILABLE upon failures. --- libraries/libldap/cyrus.c | 12 +++++++----- libraries/libldap/sasl.c | 7 ++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/libraries/libldap/cyrus.c b/libraries/libldap/cyrus.c index 6560eeebb3..1924d764ad 100644 --- a/libraries/libldap/cyrus.c +++ b/libraries/libldap/cyrus.c @@ -404,7 +404,7 @@ ldap_int_sasl_open( assert( lc->lconn_sasl_ctx == NULL ); if ( host == NULL ) { - ld->ld_errno = LDAP_UNAVAILABLE; + ld->ld_errno = LDAP_LOCAL_ERROR; return ld->ld_errno; } @@ -483,13 +483,15 @@ ldap_int_sasl_bind( if ( sd == AC_SOCKET_INVALID ) { /* not connected yet */ - int rc = ldap_open_defconn( ld ); - + int rc; + + rc = ldap_open_defconn( ld ); if( rc < 0 ) return ld->ld_errno; + ber_sockbuf_ctrl( ld->ld_sb, LBER_SB_OPT_GET_FD, &sd ); if( sd == AC_SOCKET_INVALID ) { - ld->ld_errno = LDAP_UNAVAILABLE; + ld->ld_errno = LDAP_LOCAL_ERROR; return ld->ld_errno; } } @@ -497,7 +499,7 @@ ldap_int_sasl_bind( ctx = ld->ld_defconn->lconn_sasl_ctx; if( ctx == NULL ) { - ld->ld_errno = LDAP_UNAVAILABLE; + ld->ld_errno = LDAP_LOCAL_ERROR; return ld->ld_errno; } diff --git a/libraries/libldap/sasl.c b/libraries/libldap/sasl.c index a17ca56c9e..e22b11ce96 100644 --- a/libraries/libldap/sasl.c +++ b/libraries/libldap/sasl.c @@ -366,24 +366,25 @@ ldap_pvt_sasl_getmechs ( LDAP *ld, char **pmechlist ) e = ldap_first_entry( ld, res ); if ( e == NULL ) { + ldap_msgfree( res ); if ( ld->ld_errno == LDAP_SUCCESS ) { - ld->ld_errno = LDAP_UNAVAILABLE; + ld->ld_errno = LDAP_NO_SUCH_OBJECT; } return ld->ld_errno; } values = ldap_get_values( ld, e, "supportedSASLMechanisms" ); if ( values == NULL ) { - ld->ld_errno = LDAP_NO_SUCH_ATTRIBUTE; ldap_msgfree( res ); + ld->ld_errno = LDAP_NO_SUCH_ATTRIBUTE; return ld->ld_errno; } mechlist = ldap_charray2str( values, " " ); if ( mechlist == NULL ) { - ld->ld_errno = LDAP_NO_MEMORY; LDAP_VFREE( values ); ldap_msgfree( res ); + ld->ld_errno = LDAP_NO_MEMORY; return ld->ld_errno; } -- 2.39.5