Let's lock a write lock when changing values, shall we?
authorRichard Levitte <levitte@openssl.org>
Mon, 2 Aug 2004 14:15:07 +0000 (14:15 +0000)
committerRichard Levitte <levitte@openssl.org>
Mon, 2 Aug 2004 14:15:07 +0000 (14:15 +0000)
Thanks to Dr Stephen Henson <shenson@drh-consultancy.co.uk> for making
me aware of this error.

crypto/cryptlib.c

index d1851b3085ff316306bb3b943ba084aae534c6fd..b8e700ce526f15ae8fa06724f8e0ed1cc3b21292 100644 (file)
@@ -551,13 +551,13 @@ int fips_set_owning_thread(void)
 
        if (fips_is_started())
                {
-               CRYPTO_r_lock(CRYPTO_LOCK_FIPS2);
+               CRYPTO_w_lock(CRYPTO_LOCK_FIPS2);
                if (fips_thread == 0)
                        {
                        fips_thread = CRYPTO_thread_id();
                        ret = 1;
                        }
-               CRYPTO_r_unlock(CRYPTO_LOCK_FIPS2);
+               CRYPTO_w_unlock(CRYPTO_LOCK_FIPS2);
                }
        return ret;
        }
@@ -568,13 +568,13 @@ int fips_clear_owning_thread(void)
 
        if (fips_is_started())
                {
-               CRYPTO_r_lock(CRYPTO_LOCK_FIPS2);
+               CRYPTO_w_lock(CRYPTO_LOCK_FIPS2);
                if (fips_thread == CRYPTO_thread_id())
                        {
                        fips_thread = 0;
                        ret = 1;
                        }
-               CRYPTO_r_unlock(CRYPTO_LOCK_FIPS2);
+               CRYPTO_w_unlock(CRYPTO_LOCK_FIPS2);
                }
        return ret;
        }