fix more race conditions
[openssl.git] / ssl / s2_meth.c
index d30b717..8b6cbd0 100644 (file)
@@ -77,12 +77,19 @@ SSL_METHOD *SSLv2_method(void)
 
        if (init)
                {
-               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;
+               CRYPTO_w_lock(CRYPTO_LOCK_SSL_METHOD);
+               
+               if (init)
+                       {
+                       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;
+                       }
+               
+               CRYPTO_w_unlock(CRYPTO_LOCK_SSL_METHOD);
                }
        return(&SSLv2_data);
        }