ITS#8201 LDAPSTACKGUARD feature

This commit is contained in:
Howard Chu 2015-07-16 18:58:23 +01:00
parent e5c778fa43
commit e75fbc953f
3 changed files with 15 additions and 0 deletions

View File

@ -596,6 +596,10 @@ void ldap_int_initialize_global_options( struct ldapoptions *gopts, int *dbglvl
char * ldap_int_hostname = NULL;
#endif
#ifdef LDAP_R_COMPILE
int ldap_int_stackguard;
#endif
void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl )
{
if ( gopts->ldo_valid == LDAP_INITIALIZED ) {
@ -664,6 +668,12 @@ void ldap_int_initialize( struct ldapoptions *gopts, int *dbglvl )
return;
}
#ifdef LDAP_R_COMPILE
if( getenv("LDAPSTACKGUARD") != NULL ) {
ldap_int_stackguard = 1;
}
#endif
#ifdef HAVE_CYRUS_SASL
{
/* set authentication identity to current user name */

View File

@ -495,6 +495,7 @@ struct ldap {
#ifdef LDAP_R_COMPILE
LDAP_V ( ldap_pvt_thread_mutex_t ) ldap_int_resolv_mutex;
LDAP_V ( ldap_pvt_thread_mutex_t ) ldap_int_hostname_mutex;
LDAP_V ( int ) ldap_int_stackguard;
#ifdef HAVE_GSSAPI
LDAP_V( ldap_pvt_thread_mutex_t ) ldap_int_gssapi_mutex;

View File

@ -33,6 +33,8 @@
#include "ldap_thr_debug.h" /* May rename the symbols defined below */
#include <signal.h> /* For pthread_kill() */
extern int ldap_int_stackguard;
#if HAVE_PTHREADS < 6
# define LDAP_INT_THREAD_ATTR_DEFAULT pthread_attr_default
# define LDAP_INT_THREAD_CONDATTR_DEFAULT pthread_condattr_default
@ -148,6 +150,8 @@ ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
#ifdef LDAP_PVT_THREAD_SET_STACK_SIZE
/* this should be tunable */
pthread_attr_setstacksize( &attr, LDAP_PVT_THREAD_STACK_SIZE );
if ( ldap_int_stackguard )
pthread_attr_setguardsize( &attr, LDAP_PVT_THREAD_STACK_SIZE );
#endif
#if HAVE_PTHREADS > 5