зеркало из https://github.com/mozilla/pjs.git
bug 191757, InitOIDHash() not threadsafe
r=relyea
This commit is contained in:
Родитель
5564f4e0cf
Коммит
cccb7a3f68
|
@ -32,7 +32,7 @@
|
|||
* may use your version of this file under either the MPL or the
|
||||
* GPL.
|
||||
*
|
||||
# $Id: nssinit.c,v 1.61 2003-02-20 16:58:53 wtc%netscape.com Exp $
|
||||
# $Id: nssinit.c,v 1.62 2003-02-28 21:13:15 ian.mcgreer%sun.com Exp $
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
@ -397,6 +397,8 @@ nss_FindExternalRoot(const char *dbpath, const char* secmodprefix)
|
|||
|
||||
static PRBool nss_IsInitted = PR_FALSE;
|
||||
|
||||
extern SECStatus secoid_Init(void);
|
||||
|
||||
static SECStatus
|
||||
nss_Init(const char *configdir, const char *certPrefix, const char *keyPrefix,
|
||||
const char *secmodName, PRBool readOnly, PRBool noCertDB,
|
||||
|
@ -466,6 +468,9 @@ loser:
|
|||
}
|
||||
|
||||
if (rv == SECSuccess) {
|
||||
if (secoid_Init() != SECSuccess) {
|
||||
return SECFailure;
|
||||
}
|
||||
if (STAN_LoadDefaultNSS3TrustDomain() != PR_SUCCESS) {
|
||||
return SECFailure;
|
||||
}
|
||||
|
|
|
@ -2674,6 +2674,7 @@ pk11_closePeer(PRBool isFIPS)
|
|||
}
|
||||
|
||||
static PRBool nsc_init = PR_FALSE;
|
||||
extern SECStatus secoid_Init(void);
|
||||
|
||||
/* NSC_Initialize initializes the Cryptoki library. */
|
||||
CK_RV nsc_CommonInitialize(CK_VOID_PTR pReserved, PRBool isFIPS)
|
||||
|
@ -2694,6 +2695,12 @@ CK_RV nsc_CommonInitialize(CK_VOID_PTR pReserved, PRBool isFIPS)
|
|||
}
|
||||
}
|
||||
|
||||
rv = secoid_Init();
|
||||
if (rv != SECSuccess) {
|
||||
crv = CKR_DEVICE_ERROR;
|
||||
return crv;
|
||||
}
|
||||
|
||||
rv = RNG_RNGInit(); /* initialize random number generator */
|
||||
if (rv != SECSuccess) {
|
||||
crv = CKR_DEVICE_ERROR;
|
||||
|
@ -2758,6 +2765,8 @@ CK_RV NSC_Initialize(CK_VOID_PTR pReserved)
|
|||
return crv;
|
||||
}
|
||||
|
||||
extern SECStatus SECOID_Shutdown(void);
|
||||
|
||||
/* NSC_Finalize indicates that an application is done with the
|
||||
* Cryptoki library.*/
|
||||
CK_RV nsc_CommonFinalize (CK_VOID_PTR pReserved, PRBool isFIPS)
|
||||
|
@ -2792,6 +2801,8 @@ CK_RV nsc_CommonFinalize (CK_VOID_PTR pReserved, PRBool isFIPS)
|
|||
pk11_CleanupFreeLists();
|
||||
/* tell freeBL to clean up after itself */
|
||||
BL_Cleanup();
|
||||
/* clean up the default OID table */
|
||||
SECOID_Shutdown();
|
||||
nsc_init = PR_FALSE;
|
||||
|
||||
return CKR_OK;
|
||||
|
|
|
@ -1336,12 +1336,16 @@ secoid_HashNumber(const void *key)
|
|||
}
|
||||
|
||||
|
||||
static SECStatus
|
||||
InitOIDHash(void)
|
||||
SECStatus
|
||||
secoid_Init(void)
|
||||
{
|
||||
PLHashEntry *entry;
|
||||
const SECOidData *oid;
|
||||
int i;
|
||||
|
||||
if (oidhash) {
|
||||
return PR_SUCCESS;
|
||||
}
|
||||
|
||||
oidhash = PL_NewHashTable(0, SECITEM_Hash, SECITEM_HashCompare,
|
||||
PL_CompareValues, NULL, NULL);
|
||||
|
@ -1388,13 +1392,8 @@ SECOID_FindOIDByMechanism(unsigned long mechanism)
|
|||
SECOidData *ret;
|
||||
int rv;
|
||||
|
||||
if ( !oidhash ) {
|
||||
rv = InitOIDHash();
|
||||
if ( rv != SECSuccess ) {
|
||||
PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
PR_ASSERT(oidhash != NULL);
|
||||
|
||||
ret = PL_HashTableLookupConst ( oidmechhash, (void *)mechanism);
|
||||
if ( ret == NULL ) {
|
||||
PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
|
||||
|
@ -1409,13 +1408,7 @@ SECOID_FindOID(SECItem *oid)
|
|||
SECOidData *ret;
|
||||
int rv;
|
||||
|
||||
if ( !oidhash ) {
|
||||
rv = InitOIDHash();
|
||||
if ( rv != SECSuccess ) {
|
||||
PORT_SetError(SEC_ERROR_LIBRARY_FAILURE);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
PR_ASSERT(oidhash != NULL);
|
||||
|
||||
ret = PL_HashTableLookupConst ( oidhash, oid );
|
||||
if ( ret == NULL ) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче