From: Howard Chu Date: Mon, 22 Sep 2003 23:50:33 +0000 (+0000) Subject: ITS#2717, use default SASL_MECH if none was provided. X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~677 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=38a406c8aba0e13f1bdb70bfa586b6dbee39ff6a;p=openldap ITS#2717, use default SASL_MECH if none was provided. Note that the mech stored in the void *defaults structure is useless because we can't look inside the structure, and the mech list is needed as input to the SASL library, before any callbacks are called. It seems the mech doesn't belong in the *defaults struct, and/or it should be visible and not opaque. --- diff --git a/libraries/libldap/sasl.c b/libraries/libldap/sasl.c index 1509ccd3b1..27da363e0c 100644 --- a/libraries/libldap/sasl.c +++ b/libraries/libldap/sasl.c @@ -433,6 +433,7 @@ ldap_sasl_interactive_bind_s( void *defaults ) { int rc; + char *smechs = NULL; #if defined( LDAP_R_COMPILE ) && defined( HAVE_CYRUS_SASL ) ldap_pvt_thread_mutex_lock( &ldap_int_sasl_mutex ); @@ -449,8 +450,10 @@ ldap_sasl_interactive_bind_s( } else #endif if( mechs == NULL || *mechs == '\0' ) { - char *smechs; - + mechs = ld->ld_options.ldo_def_sasl_mech; + } + + if( mechs == NULL || *mechs == '\0' ) { rc = ldap_pvt_sasl_getmechs( ld, &smechs ); if( rc != LDAP_SUCCESS ) { goto done; @@ -488,6 +491,7 @@ done: #if defined( LDAP_R_COMPILE ) && defined( HAVE_CYRUS_SASL ) ldap_pvt_thread_mutex_unlock( &ldap_int_sasl_mutex ); #endif + if ( smechs ) LDAP_FREE( smechs ); return rc; }