mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-21 03:10:25 +08:00
ITS#7270 Protect accesses to ldap_int_hostname with a mutex.
Not protecting the accesses to ldap_int_hostname could lead to a double free.
This commit is contained in:
parent
d0296e6e33
commit
8bb9e88d5f
@ -642,6 +642,7 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl )
|
|||||||
|
|
||||||
#if defined(HAVE_TLS) || defined(HAVE_CYRUS_SASL)
|
#if defined(HAVE_TLS) || defined(HAVE_CYRUS_SASL)
|
||||||
{
|
{
|
||||||
|
LDAP_MUTEX_LOCK( &ldap_int_hostname_mutex );
|
||||||
char *name = ldap_int_hostname;
|
char *name = ldap_int_hostname;
|
||||||
|
|
||||||
ldap_int_hostname = ldap_pvt_get_fqdn( name );
|
ldap_int_hostname = ldap_pvt_get_fqdn( name );
|
||||||
@ -649,6 +650,7 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl )
|
|||||||
if ( name != NULL && name != ldap_int_hostname ) {
|
if ( name != NULL && name != ldap_int_hostname ) {
|
||||||
LDAP_FREE( name );
|
LDAP_FREE( name );
|
||||||
}
|
}
|
||||||
|
LDAP_MUTEX_UNLOCK( &ldap_int_hostname_mutex );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -488,6 +488,7 @@ struct ldap {
|
|||||||
|
|
||||||
#ifdef LDAP_R_COMPILE
|
#ifdef LDAP_R_COMPILE
|
||||||
LDAP_V ( ldap_pvt_thread_mutex_t ) ldap_int_resolv_mutex;
|
LDAP_V ( ldap_pvt_thread_mutex_t ) ldap_int_resolv_mutex;
|
||||||
|
LDAP_V ( ldap_pvt_thread_mutex_t ) ldap_int_hostname_mutex;
|
||||||
|
|
||||||
#ifdef HAVE_CYRUS_SASL
|
#ifdef HAVE_CYRUS_SASL
|
||||||
LDAP_V( ldap_pvt_thread_mutex_t ) ldap_int_sasl_mutex;
|
LDAP_V( ldap_pvt_thread_mutex_t ) ldap_int_sasl_mutex;
|
||||||
|
@ -58,6 +58,7 @@ extern int h_errno;
|
|||||||
#else
|
#else
|
||||||
# include <ldap_pvt_thread.h>
|
# include <ldap_pvt_thread.h>
|
||||||
ldap_pvt_thread_mutex_t ldap_int_resolv_mutex;
|
ldap_pvt_thread_mutex_t ldap_int_resolv_mutex;
|
||||||
|
ldap_pvt_thread_mutex_t ldap_int_hostname_mutex;
|
||||||
|
|
||||||
# if (defined( HAVE_CTIME_R ) || defined( HAVE_REENTRANT_FUNCTIONS)) \
|
# if (defined( HAVE_CTIME_R ) || defined( HAVE_REENTRANT_FUNCTIONS)) \
|
||||||
&& defined( CTIME_R_NARGS )
|
&& defined( CTIME_R_NARGS )
|
||||||
@ -603,6 +604,8 @@ void ldap_int_utils_init( void )
|
|||||||
#endif
|
#endif
|
||||||
ldap_pvt_thread_mutex_init( &ldap_int_resolv_mutex );
|
ldap_pvt_thread_mutex_init( &ldap_int_resolv_mutex );
|
||||||
|
|
||||||
|
ldap_pvt_thread_mutex_init( &ldap_int_hostname_mutex );
|
||||||
|
|
||||||
#ifdef HAVE_CYRUS_SASL
|
#ifdef HAVE_CYRUS_SASL
|
||||||
ldap_pvt_thread_mutex_init( &ldap_int_sasl_mutex );
|
ldap_pvt_thread_mutex_init( &ldap_int_sasl_mutex );
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user