Latest update - pre9
This commit is contained in:
+13
-5
@@ -13,6 +13,7 @@
|
||||
#include <openssl/x509v3.h>
|
||||
#include <openssl/x509_vfy.h>
|
||||
#include "internal/x509_int.h"
|
||||
#include "internal/tsan_assist.h"
|
||||
|
||||
static void x509v3_cache_extensions(X509 *x);
|
||||
|
||||
@@ -133,13 +134,14 @@ int X509_PURPOSE_get_by_id(int purpose)
|
||||
{
|
||||
X509_PURPOSE tmp;
|
||||
int idx;
|
||||
|
||||
if ((purpose >= X509_PURPOSE_MIN) && (purpose <= X509_PURPOSE_MAX))
|
||||
return purpose - X509_PURPOSE_MIN;
|
||||
tmp.purpose = purpose;
|
||||
if (!xptable)
|
||||
if (xptable == NULL)
|
||||
return -1;
|
||||
tmp.purpose = purpose;
|
||||
idx = sk_X509_PURPOSE_find(xptable, &tmp);
|
||||
if (idx == -1)
|
||||
if (idx < 0)
|
||||
return -1;
|
||||
return idx + X509_PURPOSE_COUNT;
|
||||
}
|
||||
@@ -350,10 +352,10 @@ static void x509v3_cache_extensions(X509 *x)
|
||||
ASN1_BIT_STRING *ns;
|
||||
EXTENDED_KEY_USAGE *extusage;
|
||||
X509_EXTENSION *ex;
|
||||
|
||||
int i;
|
||||
|
||||
if (x->ex_flags & EXFLAG_SET)
|
||||
/* fast lock-free check, see end of the function for details. */
|
||||
if (tsan_load((TSAN_QUALIFIER int *)&x->ex_cached))
|
||||
return;
|
||||
|
||||
CRYPTO_THREAD_write_lock(x->lock);
|
||||
@@ -497,6 +499,12 @@ static void x509v3_cache_extensions(X509 *x)
|
||||
x509_init_sig_info(x);
|
||||
x->ex_flags |= EXFLAG_SET;
|
||||
CRYPTO_THREAD_unlock(x->lock);
|
||||
/*
|
||||
* It has to be placed after memory barrier, which is implied by unlock.
|
||||
* Worst thing that can happen is that another thread proceeds to lock
|
||||
* and checks x->ex_flags & EXFLAGS_SET. See beginning of the function.
|
||||
*/
|
||||
tsan_store((TSAN_QUALIFIER int *)&x->ex_cached, 1);
|
||||
}
|
||||
|
||||
/*-
|
||||
|
||||
Reference in New Issue
Block a user