]> git.sur5r.net Git - openldap/commitdiff
ITS#8201 LDAPSTACKGUARD feature
authorHoward Chu <hyc@openldap.org>
Thu, 16 Jul 2015 17:58:23 +0000 (18:58 +0100)
committerHoward Chu <hyc@openldap.org>
Thu, 16 Jul 2015 17:58:23 +0000 (18:58 +0100)
libraries/libldap/init.c
libraries/libldap/ldap-int.h
libraries/libldap_r/thr_posix.c

index 68ff401d3f07fa62cb39c067897460a5d8bee2e0..9b9f6177bdddd81a58128359f31182da11f06c9b 100644 (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 */
index fbcf93965cb0bc21a0cf7f01a384fc6bdbaecabb..5482572539b092c84968015f28cdb9e19cf3f833 100644 (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;
index ec6677f8c7beb1a7f713006d4e4f8fd1eb61ec0a..ce6cb206c5d02d0cce4fb11c8f768db52b21fdc9 100644 (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