From 90fe4bd927a6e57cdd2e71f0302c64a350236ab5 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Tue, 12 Jun 2007 23:57:08 +0000 Subject: [PATCH] ITS#4983: Partly revert tls_thread_self() paranoia from rev 1.154: Only require that ldap_pvt_thread_t can be cast to u.long and is not wider. ITS#5010: In ldap_X509dn2bv(), catch error return from ber_decode_oid(). --- libraries/libldap/tls.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/libraries/libldap/tls.c b/libraries/libldap/tls.c index f0cda0de32..8d15e94ead 100644 --- a/libraries/libldap/tls.c +++ b/libraries/libldap/tls.c @@ -406,16 +406,11 @@ static unsigned long tls_thread_self( void ) * 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 */ - }; + /* force an error if the ldap_pvt_thread_t type is too large */ + enum { ok = sizeof( ldap_pvt_thread_t ) <= sizeof( unsigned long ) }; typedef struct { int dummy: ok ? 1 : -1; } Check[ok ? 1 : -1]; - return ldap_pvt_thread_self(); + return (unsigned long) ldap_pvt_thread_self(); } static void tls_init_threads( void ) @@ -3032,7 +3027,10 @@ ldap_X509dn2bv( void *x509_name, struct berval *bv, LDAPDN_rewrite_func *func, oid2.bv_val = oidptr; oid2.bv_len = oidrem; - ber_decode_oid( &Oid, &oid2 ); + if ( ber_decode_oid( &Oid, &oid2 ) < 0 ) { + rc = LDAP_DECODING_ERROR; + goto nomem; + } oidname = find_oid( &oid2 ); if ( !oidname ) { newAVA->la_attr = oid2; -- 2.39.5