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 6c0e5a41062173fc07d699f361ec1acf7250fdd6..9de7b1d5c94794d23be385ed67e883a125c9d81f 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 dbf13e686fe1525440228d5305130eae8cc9b97b..5b2db35aaecb22fab0b84fc02fce9fa96ab88376 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 a00dda754f6458c5589d07fa0e5d864fd5027431..febd36dfce796c9781476b1ee2df16608970f31b 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 61c74201355fb28c0b9488c9c45b56f1cedebc8e..c7f85a621f3d17483b885cee06134c7d36174483 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 edcbdbb2bd14cb35af5d632a5f0ac666e5aa262e..f1f81325be2410f4d9e73131a3fa5d833bc2cc7b 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 8dc0a0608fce8528f686b16575636c759eb5d48b..f626c9cb0611023d64babe2212e045909d036f93 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 5652549dac75692c82bb92750189cc6d108a93a8..3a79fd7412ac14e09767b8cdb893b63680acb97d 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 43c7cab3edef4dc122c59f57ae0167f4796eed25..4c734c9acfca615f28461751541a87ed70ca8d2a 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 7d7eed8a8f18b77047f404bd7712c47aeec874dd..96ac159ce410f436e46272556afd2edd045c5e05 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 83621290fb52fc34f709968f5fb026943139a1e7..d472d5d5af7a405c8849ff7ce9c63940dac86aa6 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 4e58bcd632814a9cfcc7ee01f4775de2da6f64b8..12f7ec60b6bfdcd6a622a4adf9098886046d80eb 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 d9cd9c2210130020ddd7f3ebd71ab4ec71e208f7..d70165cb4006875d634764b1bb2fe43ce50ec2b8 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 06e5268a54b2f7e61d5f8cf8c18e677218efcb0d..d3c2680e5636ddd1c5e24d49e06cc9aac6b11317 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 3cc03e38877fba7f3aa2df09e2bc1f0dd4d124bf..429ad0eca5d9ee661f62e854cdbfd042313c701f 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 fb065d2c94cc5a47fd4c421ec14d553a8041bd74..888ea3e6a8e7a878ba5fb93cbcde54b2668548ca 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 56038792845ad03bbfdea8ea9530150953b23d37..7e65f263fc0a07426519abf7df8d645e796a4098 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);
        }