mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-30 13:30:57 +08:00
libldap/tls.c calls CRYPTO_set_id_callback(ldap_pvt_thread_self), which
causes ldap_pvt_thread_self to be called with the wrong prototype. That can cause OpenSSL to use a garbage value, e.g. if the unsigned long it expects takes two words but ldap_pvt_thread_t is an int. I'm fixing it in HEAD now and also provoking an error if unsigned long cannot hold a ldap_pvt_thread_t. Otherwise it can silently compile to broken code. Maybe the latter should go in configure, but since OpenSSL presumably breaks anyway if that fails I don't see much point at this time.
This commit is contained in:
parent
9fd99cd566
commit
c47e444698
@ -397,6 +397,24 @@ static void tls_locking_cb( int mode, int type, const char *file, int line )
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned long tls_thread_self( void )
|
||||
{
|
||||
/* FIXME: CRYPTO_set_id_callback only works when ldap_pvt_thread_t
|
||||
* is an integral type that fits in an unsigned long
|
||||
*/
|
||||
|
||||
/* force an error if ldap_pvt_thread_t is not such a type */
|
||||
enum {
|
||||
ok =
|
||||
3 / (ldap_pvt_thread_t)2 == 1 /* integer */
|
||||
&& (ldap_pvt_thread_t)-1 > 0UL /* not too wide signed */
|
||||
&& (ldap_pvt_thread_t)-2 < -1UL /* not too wide unsigned */
|
||||
};
|
||||
typedef struct { int dummy: ok ? 1 : -1; } Check[ok ? 1 : -1];
|
||||
|
||||
return ldap_pvt_thread_self();
|
||||
}
|
||||
|
||||
static void tls_init_threads( void )
|
||||
{
|
||||
int i;
|
||||
@ -405,10 +423,7 @@ static void tls_init_threads( void )
|
||||
ldap_pvt_thread_mutex_init( &tls_mutexes[i] );
|
||||
}
|
||||
CRYPTO_set_locking_callback( tls_locking_cb );
|
||||
CRYPTO_set_id_callback( ldap_pvt_thread_self );
|
||||
/* FIXME: CRYPTO_set_id_callback only works when ldap_pvt_thread_t
|
||||
* is an integral type that fits in an unsigned long
|
||||
*/
|
||||
CRYPTO_set_id_callback( tls_thread_self );
|
||||
}
|
||||
#endif /* LDAP_R_COMPILE */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user