Fixed some race conditions.
authorBodo Möller <bodo@openssl.org>
Thu, 22 Apr 1999 13:37:46 +0000 (13:37 +0000)
committerBodo Möller <bodo@openssl.org>
Thu, 22 Apr 1999 13:37:46 +0000 (13:37 +0000)
Submitted by:
Reviewed by:
PR:

16 files changed:
crypto/des/ecb_enc.c
crypto/rand/md_rand.c
crypto/x509v3/v3err.c
ssl/s23_clnt.c
ssl/s23_meth.c
ssl/s23_srvr.c
ssl/s2_clnt.c
ssl/s2_lib.c
ssl/s2_meth.c
ssl/s2_srvr.c
ssl/s3_lib.c
ssl/s3_meth.c
ssl/s3_srvr.c
ssl/t1_clnt.c
ssl/t1_meth.c
ssl/t1_srvr.c

index 6c0e5a4..9de7b1d 100644 (file)
@@ -72,7 +72,6 @@ const char *des_options(void)
                {
                const char *ptr,*unroll,*risc,*size;
 
-               init=0;
 #ifdef DES_PTR
                ptr="ptr";
 #else
@@ -98,6 +97,7 @@ const char *des_options(void)
                else
                        size="long";
                sprintf(buf,"des(%s,%s,%s,%s)",ptr,risc,unroll,size);
+               init=0;
                }
        return(buf);
        }
index dbf13e6..5b2db35 100644 (file)
@@ -241,7 +241,6 @@ static void ssleay_rand_bytes(unsigned char *buf, int num)
 
        if (init)
                {
-               init=0;
                CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
                /* put in some default random data, we need more than
                 * just this */
@@ -281,6 +280,7 @@ static void ssleay_rand_bytes(unsigned char *buf, int num)
                memset(md,0,MD_DIGEST_LENGTH);
 #endif
                CRYPTO_w_lock(CRYPTO_LOCK_RAND);
+               init=0;
                }
 
        st_idx=state_index;
index a00dda7..febd36d 100644 (file)
@@ -151,7 +151,7 @@ static ERR_STRING_DATA X509V3_str_reasons[]=
 
 #endif
 
-void ERR_load_X509V3_strings(void)
+void ERR_load_X509V3_strings()
        {
        static int init=1;
 
index 61c7420..c7f85a6 100644 (file)
@@ -94,11 +94,11 @@ SSL_METHOD *SSLv23_client_method(void)
 
        if (init)
                {
-               init=0;
                memcpy((char *)&SSLv23_client_data,
                        (char *)sslv23_base_method(),sizeof(SSL_METHOD));
                SSLv23_client_data.ssl_connect=ssl23_connect;
                SSLv23_client_data.get_ssl_method=ssl23_get_client_method;
+               init=0;
                }
        return(&SSLv23_client_data);
        }
index edcbdbb..f1f8132 100644 (file)
@@ -85,12 +85,12 @@ SSL_METHOD *SSLv23_method(void)
 
        if (init)
                {
-               init=0;
                memcpy((char *)&SSLv23_data,(char *)sslv23_base_method(),
                        sizeof(SSL_METHOD));
                SSLv23_data.ssl_connect=ssl23_connect;
                SSLv23_data.ssl_accept=ssl23_accept;
                SSLv23_data.get_ssl_method=ssl23_get_method;
+               init=0;
                }
        return(&SSLv23_data);
        }
index 8dc0a06..f626c9c 100644 (file)
@@ -92,11 +92,11 @@ SSL_METHOD *SSLv23_server_method(void)
 
        if (init)
                {
-               init=0;
                memcpy((char *)&SSLv23_server_data,
                        (char *)sslv23_base_method(),sizeof(SSL_METHOD));
                SSLv23_server_data.ssl_accept=ssl23_accept;
                SSLv23_server_data.get_ssl_method=ssl23_get_server_method;
+               init=0;
                }
        return(&SSLv23_server_data);
        }
index 5652549..3a79fd7 100644 (file)
@@ -103,11 +103,11 @@ SSL_METHOD *SSLv2_client_method(void)
 
        if (init)
                {
-               init=0;
                memcpy((char *)&SSLv2_client_data,(char *)sslv2_base_method(),
                        sizeof(SSL_METHOD));
                SSLv2_client_data.ssl_connect=ssl2_connect;
                SSLv2_client_data.get_ssl_method=ssl2_get_client_method;
+               init=0;
                }
        return(&SSLv2_client_data);
        }
index 43c7cab..4c734c9 100644 (file)
@@ -316,7 +316,7 @@ SSL_CIPHER *ssl2_get_cipher_by_char(const unsigned char *p)
 
        if (init)
                {
-               init=0;
+               CRYPTO_w_lock(CRYPTO_LOCK_SSL);
 
                for (i=0; i<SSL2_NUM_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,
                        SSL2_NUM_CIPHERS,sizeof(SSL_CIPHER *),
                        FP_ICC ssl_cipher_ptr_id_cmp);
+
+               CRYPTO_w_unlock(CRYPTO_LOCK_SSL);
+               init=0;
                }
 
        id=0x02000000L|((unsigned long)p[0]<<16L)|
index 7d7eed8..96ac159 100644 (file)
@@ -81,12 +81,12 @@ SSL_METHOD *SSLv2_method(void)
 
        if (init)
                {
-               init=0;
                memcpy((char *)&SSLv2_data,(char *)sslv2_base_method(),
                        sizeof(SSL_METHOD));
                SSLv2_data.ssl_connect=ssl2_connect;
                SSLv2_data.ssl_accept=ssl2_accept;
                SSLv2_data.get_ssl_method=ssl2_get_method;
+               init=0;
                }
        return(&SSLv2_data);
        }
index 8362129..d472d5d 100644 (file)
@@ -103,11 +103,11 @@ SSL_METHOD *SSLv2_server_method(void)
 
        if (init)
                {
-               init=0;
                memcpy((char *)&SSLv2_server_data,(char *)sslv2_base_method(),
                        sizeof(SSL_METHOD));
                SSLv2_server_data.ssl_accept=ssl2_accept;
                SSLv2_server_data.get_ssl_method=ssl2_get_server_method;
+               init=0;
                }
        return(&SSLv2_server_data);
        }
index 4e58bcd..12f7ec6 100644 (file)
@@ -797,7 +797,7 @@ SSL_CIPHER *ssl3_get_cipher_by_char(const unsigned char *p)
 
        if (init)
                {
-               init=0;
+               CRYPTO_w_lock(CRYPTO_LOCK_SSL);
 
                for (i=0; i<SSL3_NUM_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,
                        SSL3_NUM_CIPHERS,sizeof(SSL_CIPHER *),
                        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];
index d9cd9c2..d70165c 100644 (file)
@@ -81,12 +81,12 @@ SSL_METHOD *SSLv3_method(void)
 
        if (init)
                {
-               init=0;
                memcpy((char *)&SSLv3_data,(char *)sslv3_base_method(),
                        sizeof(SSL_METHOD));
                SSLv3_data.ssl_connect=ssl3_connect;
                SSLv3_data.ssl_accept=ssl3_accept;
                SSLv3_data.get_ssl_method=ssl3_get_method;
+               init=0;
                }
        return(&SSLv3_data);
        }
index 06e5268..d3c2680 100644 (file)
@@ -116,11 +116,11 @@ SSL_METHOD *SSLv3_server_method(void)
 
        if (init)
                {
-               init=0;
                memcpy((char *)&SSLv3_server_data,(char *)sslv3_base_method(),
                        sizeof(SSL_METHOD));
                SSLv3_server_data.ssl_accept=ssl3_accept;
                SSLv3_server_data.get_ssl_method=ssl3_get_server_method;
+               init=0;
                }
        return(&SSLv3_server_data);
        }
index 3cc03e3..429ad0e 100644 (file)
@@ -84,11 +84,11 @@ SSL_METHOD *TLSv1_client_method(void)
 
        if (init)
                {
-               init=0;
                memcpy((char *)&TLSv1_client_data,(char *)tlsv1_base_method(),
                        sizeof(SSL_METHOD));
                TLSv1_client_data.ssl_connect=ssl3_connect;
                TLSv1_client_data.get_ssl_method=tls1_get_client_method;
+               init=0;
                }
        return(&TLSv1_client_data);
        }
index fb065d2..888ea3e 100644 (file)
@@ -81,12 +81,12 @@ SSL_METHOD *TLSv1_method(void)
 
        if (init)
                {
-               init=0;
                memcpy((char *)&TLSv1_data,(char *)tlsv1_base_method(),
                        sizeof(SSL_METHOD));
                TLSv1_data.ssl_connect=ssl3_connect;
                TLSv1_data.ssl_accept=ssl3_accept;
                TLSv1_data.get_ssl_method=tls1_get_method;
+               init=0;
                }
        return(&TLSv1_data);
        }
index 5603879..7e65f26 100644 (file)
@@ -85,11 +85,11 @@ SSL_METHOD *TLSv1_server_method(void)
 
        if (init)
                {
-               init=0;
                memcpy((char *)&TLSv1_server_data,(char *)tlsv1_base_method(),
                        sizeof(SSL_METHOD));
                TLSv1_server_data.ssl_accept=ssl3_accept;
                TLSv1_server_data.get_ssl_method=tls1_get_server_method;
+               init=0;
                }
        return(&TLSv1_server_data);
        }