Fixed some race conditions.

Submitted by:
Reviewed by:
PR:
This commit is contained in:
Bodo Möller 1999-04-22 13:37:46 +00:00
parent 4cd401e401
commit 5cc146f344
16 changed files with 23 additions and 16 deletions

View File

@ -72,7 +72,6 @@ const char *des_options(void)
{ {
const char *ptr,*unroll,*risc,*size; const char *ptr,*unroll,*risc,*size;
init=0;
#ifdef DES_PTR #ifdef DES_PTR
ptr="ptr"; ptr="ptr";
#else #else
@ -98,6 +97,7 @@ const char *des_options(void)
else else
size="long"; size="long";
sprintf(buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,size); sprintf(buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,size);
init=0;
} }
return(buf); return(buf);
} }

View File

@ -241,7 +241,6 @@ static void ssleay_rand_bytes(unsigned char *buf, int num)
if (init) if (init)
{ {
init=0;
CRYPTO_w_unlock(CRYPTO_LOCK_RAND); CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
/* put in some default random data, we need more than /* put in some default random data, we need more than
* just this */ * just this */
@ -281,6 +280,7 @@ static void ssleay_rand_bytes(unsigned char *buf, int num)
memset(md,0,MD_DIGEST_LENGTH); memset(md,0,MD_DIGEST_LENGTH);
#endif #endif
CRYPTO_w_lock(CRYPTO_LOCK_RAND); CRYPTO_w_lock(CRYPTO_LOCK_RAND);
init=0;
} }
st_idx=state_index; st_idx=state_index;

View File

@ -151,7 +151,7 @@ static ERR_STRING_DATA X509V3_str_reasons[]=
#endif #endif
void ERR_load_X509V3_strings(void) void ERR_load_X509V3_strings()
{ {
static int init=1; static int init=1;

View File

@ -94,11 +94,11 @@ SSL_METHOD *SSLv23_client_method(void)
if (init) if (init)
{ {
init=0;
memcpy((char *)&SSLv23_client_data, memcpy((char *)&SSLv23_client_data,
(char *)sslv23_base_method(),sizeof(SSL_METHOD)); (char *)sslv23_base_method(),sizeof(SSL_METHOD));
SSLv23_client_data.ssl_connect=ssl23_connect; SSLv23_client_data.ssl_connect=ssl23_connect;
SSLv23_client_data.get_ssl_method=ssl23_get_client_method; SSLv23_client_data.get_ssl_method=ssl23_get_client_method;
init=0;
} }
return(&SSLv23_client_data); return(&SSLv23_client_data);
} }

View File

@ -85,12 +85,12 @@ SSL_METHOD *SSLv23_method(void)
if (init) if (init)
{ {
init=0;
memcpy((char *)&SSLv23_data,(char *)sslv23_base_method(), memcpy((char *)&SSLv23_data,(char *)sslv23_base_method(),
sizeof(SSL_METHOD)); sizeof(SSL_METHOD));
SSLv23_data.ssl_connect=ssl23_connect; SSLv23_data.ssl_connect=ssl23_connect;
SSLv23_data.ssl_accept=ssl23_accept; SSLv23_data.ssl_accept=ssl23_accept;
SSLv23_data.get_ssl_method=ssl23_get_method; SSLv23_data.get_ssl_method=ssl23_get_method;
init=0;
} }
return(&SSLv23_data); return(&SSLv23_data);
} }

View File

@ -92,11 +92,11 @@ SSL_METHOD *SSLv23_server_method(void)
if (init) if (init)
{ {
init=0;
memcpy((char *)&SSLv23_server_data, memcpy((char *)&SSLv23_server_data,
(char *)sslv23_base_method(),sizeof(SSL_METHOD)); (char *)sslv23_base_method(),sizeof(SSL_METHOD));
SSLv23_server_data.ssl_accept=ssl23_accept; SSLv23_server_data.ssl_accept=ssl23_accept;
SSLv23_server_data.get_ssl_method=ssl23_get_server_method; SSLv23_server_data.get_ssl_method=ssl23_get_server_method;
init=0;
} }
return(&SSLv23_server_data); return(&SSLv23_server_data);
} }

View File

@ -103,11 +103,11 @@ SSL_METHOD *SSLv2_client_method(void)
if (init) if (init)
{ {
init=0;
memcpy((char *)&SSLv2_client_data,(char *)sslv2_base_method(), memcpy((char *)&SSLv2_client_data,(char *)sslv2_base_method(),
sizeof(SSL_METHOD)); sizeof(SSL_METHOD));
SSLv2_client_data.ssl_connect=ssl2_connect; SSLv2_client_data.ssl_connect=ssl2_connect;
SSLv2_client_data.get_ssl_method=ssl2_get_client_method; SSLv2_client_data.get_ssl_method=ssl2_get_client_method;
init=0;
} }
return(&SSLv2_client_data); return(&SSLv2_client_data);
} }

View File

@ -316,7 +316,7 @@ SSL_CIPHER *ssl2_get_cipher_by_char(const unsigned char *p)
if (init) if (init)
{ {
init=0; CRYPTO_w_lock(CRYPTO_LOCK_SSL);
for (i=0; i<SSL2_NUM_CIPHERS; i++) for (i=0; i<SSL2_NUM_CIPHERS; i++)
sorted[i]= &(ssl2_ciphers[i]); sorted[i]= &(ssl2_ciphers[i]);
@ -324,6 +324,9 @@ SSL_CIPHER *ssl2_get_cipher_by_char(const unsigned char *p)
qsort( (char *)sorted, qsort( (char *)sorted,
SSL2_NUM_CIPHERS,sizeof(SSL_CIPHER *), SSL2_NUM_CIPHERS,sizeof(SSL_CIPHER *),
FP_ICC ssl_cipher_ptr_id_cmp); FP_ICC ssl_cipher_ptr_id_cmp);
CRYPTO_w_unlock(CRYPTO_LOCK_SSL);
init=0;
} }
id=0x02000000L|((unsigned long)p[0]<<16L)| id=0x02000000L|((unsigned long)p[0]<<16L)|

View File

@ -81,12 +81,12 @@ SSL_METHOD *SSLv2_method(void)
if (init) if (init)
{ {
init=0;
memcpy((char *)&SSLv2_data,(char *)sslv2_base_method(), memcpy((char *)&SSLv2_data,(char *)sslv2_base_method(),
sizeof(SSL_METHOD)); sizeof(SSL_METHOD));
SSLv2_data.ssl_connect=ssl2_connect; SSLv2_data.ssl_connect=ssl2_connect;
SSLv2_data.ssl_accept=ssl2_accept; SSLv2_data.ssl_accept=ssl2_accept;
SSLv2_data.get_ssl_method=ssl2_get_method; SSLv2_data.get_ssl_method=ssl2_get_method;
init=0;
} }
return(&SSLv2_data); return(&SSLv2_data);
} }

View File

@ -103,11 +103,11 @@ SSL_METHOD *SSLv2_server_method(void)
if (init) if (init)
{ {
init=0;
memcpy((char *)&SSLv2_server_data,(char *)sslv2_base_method(), memcpy((char *)&SSLv2_server_data,(char *)sslv2_base_method(),
sizeof(SSL_METHOD)); sizeof(SSL_METHOD));
SSLv2_server_data.ssl_accept=ssl2_accept; SSLv2_server_data.ssl_accept=ssl2_accept;
SSLv2_server_data.get_ssl_method=ssl2_get_server_method; SSLv2_server_data.get_ssl_method=ssl2_get_server_method;
init=0;
} }
return(&SSLv2_server_data); return(&SSLv2_server_data);
} }

View File

@ -797,7 +797,7 @@ SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
if (init) if (init)
{ {
init=0; CRYPTO_w_lock(CRYPTO_LOCK_SSL);
for (i=0; i<SSL3_NUM_CIPHERS; i++) for (i=0; i<SSL3_NUM_CIPHERS; i++)
sorted[i]= &(ssl3_ciphers[i]); sorted[i]= &(ssl3_ciphers[i]);
@ -805,6 +805,10 @@ SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
qsort( (char *)sorted, qsort( (char *)sorted,
SSL3_NUM_CIPHERS,sizeof(SSL_CIPHER *), SSL3_NUM_CIPHERS,sizeof(SSL_CIPHER *),
FP_ICC ssl_cipher_ptr_id_cmp); FP_ICC ssl_cipher_ptr_id_cmp);
CRYPTO_w_unlock(CRYPTO_LOCK_SSL);
init=0;
} }
id=0x03000000L|((unsigned long)p[0]<<8L)|(unsigned long)p[1]; id=0x03000000L|((unsigned long)p[0]<<8L)|(unsigned long)p[1];

View File

@ -81,12 +81,12 @@ SSL_METHOD *SSLv3_method(void)
if (init) if (init)
{ {
init=0;
memcpy((char *)&SSLv3_data,(char *)sslv3_base_method(), memcpy((char *)&SSLv3_data,(char *)sslv3_base_method(),
sizeof(SSL_METHOD)); sizeof(SSL_METHOD));
SSLv3_data.ssl_connect=ssl3_connect; SSLv3_data.ssl_connect=ssl3_connect;
SSLv3_data.ssl_accept=ssl3_accept; SSLv3_data.ssl_accept=ssl3_accept;
SSLv3_data.get_ssl_method=ssl3_get_method; SSLv3_data.get_ssl_method=ssl3_get_method;
init=0;
} }
return(&SSLv3_data); return(&SSLv3_data);
} }

View File

@ -116,11 +116,11 @@ SSL_METHOD *SSLv3_server_method(void)
if (init) if (init)
{ {
init=0;
memcpy((char *)&SSLv3_server_data,(char *)sslv3_base_method(), memcpy((char *)&SSLv3_server_data,(char *)sslv3_base_method(),
sizeof(SSL_METHOD)); sizeof(SSL_METHOD));
SSLv3_server_data.ssl_accept=ssl3_accept; SSLv3_server_data.ssl_accept=ssl3_accept;
SSLv3_server_data.get_ssl_method=ssl3_get_server_method; SSLv3_server_data.get_ssl_method=ssl3_get_server_method;
init=0;
} }
return(&SSLv3_server_data); return(&SSLv3_server_data);
} }

View File

@ -84,11 +84,11 @@ SSL_METHOD *TLSv1_client_method(void)
if (init) if (init)
{ {
init=0;
memcpy((char *)&TLSv1_client_data,(char *)tlsv1_base_method(), memcpy((char *)&TLSv1_client_data,(char *)tlsv1_base_method(),
sizeof(SSL_METHOD)); sizeof(SSL_METHOD));
TLSv1_client_data.ssl_connect=ssl3_connect; TLSv1_client_data.ssl_connect=ssl3_connect;
TLSv1_client_data.get_ssl_method=tls1_get_client_method; TLSv1_client_data.get_ssl_method=tls1_get_client_method;
init=0;
} }
return(&TLSv1_client_data); return(&TLSv1_client_data);
} }

View File

@ -81,12 +81,12 @@ SSL_METHOD *TLSv1_method(void)
if (init) if (init)
{ {
init=0;
memcpy((char *)&TLSv1_data,(char *)tlsv1_base_method(), memcpy((char *)&TLSv1_data,(char *)tlsv1_base_method(),
sizeof(SSL_METHOD)); sizeof(SSL_METHOD));
TLSv1_data.ssl_connect=ssl3_connect; TLSv1_data.ssl_connect=ssl3_connect;
TLSv1_data.ssl_accept=ssl3_accept; TLSv1_data.ssl_accept=ssl3_accept;
TLSv1_data.get_ssl_method=tls1_get_method; TLSv1_data.get_ssl_method=tls1_get_method;
init=0;
} }
return(&TLSv1_data); return(&TLSv1_data);
} }

View File

@ -85,11 +85,11 @@ SSL_METHOD *TLSv1_server_method(void)
if (init) if (init)
{ {
init=0;
memcpy((char *)&TLSv1_server_data,(char *)tlsv1_base_method(), memcpy((char *)&TLSv1_server_data,(char *)tlsv1_base_method(),
sizeof(SSL_METHOD)); sizeof(SSL_METHOD));
TLSv1_server_data.ssl_accept=ssl3_accept; TLSv1_server_data.ssl_accept=ssl3_accept;
TLSv1_server_data.get_ssl_method=tls1_get_server_method; TLSv1_server_data.get_ssl_method=tls1_get_server_method;
init=0;
} }
return(&TLSv1_server_data); return(&TLSv1_server_data);
} }