summaryrefslogtreecommitdiff
path: root/security/nss/lib/ssl
diff options
context:
space:
mode:
authorjpierre%netscape.com <devnull@localhost>2004-06-19 03:21:39 +0000
committerjpierre%netscape.com <devnull@localhost>2004-06-19 03:21:39 +0000
commitc96af1bf8b3698e54fbe45504da2858b9ec13cbd (patch)
tree16ffd38fecbaf6bad7c69ffc27e50aaabfaa0797 /security/nss/lib/ssl
parentb8e5cff0379ad4248e134ce470b5dcabb5726312 (diff)
downloadnss-hg-c96af1bf8b3698e54fbe45504da2858b9ec13cbd.tar.gz
Fix for 237934 - nss_InitLock not atomic. r=nelson
Diffstat (limited to 'security/nss/lib/ssl')
-rw-r--r--security/nss/lib/ssl/ssl3con.c13
-rw-r--r--security/nss/lib/ssl/sslimpl.h4
-rw-r--r--security/nss/lib/ssl/sslnonce.c16
-rw-r--r--security/nss/lib/ssl/sslsnce.c6
4 files changed, 28 insertions, 11 deletions
diff --git a/security/nss/lib/ssl/ssl3con.c b/security/nss/lib/ssl/ssl3con.c
index 37e43d693..1c9d3d142 100644
--- a/security/nss/lib/ssl/ssl3con.c
+++ b/security/nss/lib/ssl/ssl3con.c
@@ -3333,7 +3333,7 @@ typedef struct {
PK11SymKey * symWrapKey[kt_kea_size];
} ssl3SymWrapKey;
-static PZLock * symWrapKeysLock;
+static PZLock * symWrapKeysLock = NULL;
static ssl3SymWrapKey symWrapKeys[SSL_NUM_WRAP_MECHS];
SECStatus
@@ -3360,6 +3360,13 @@ SSL3_ShutdownServerCache(void)
return SECSuccess;
}
+void ssl_InitSymWrapKeysLock(void)
+{
+ /* atomically initialize the lock */
+ if (!symWrapKeysLock)
+ nss_InitLock(&symWrapKeysLock, nssILockOther);
+}
+
/* Try to get wrapping key for mechanism from in-memory array.
* If that fails, look for one on disk.
* If that fails, generate a new one, put the new one on disk,
@@ -3397,9 +3404,7 @@ getWrappingKey( sslSocket * ss,
pSymWrapKey = &symWrapKeys[symWrapMechIndex].symWrapKey[exchKeyType];
- /* atomically initialize the lock */
- if (!symWrapKeysLock)
- nss_InitLock(&symWrapKeysLock, nssILockOther);
+ ssl_InitSymWrapKeysLock();
PZ_Lock(symWrapKeysLock);
diff --git a/security/nss/lib/ssl/sslimpl.h b/security/nss/lib/ssl/sslimpl.h
index 80aec4b6e..1064f3bcc 100644
--- a/security/nss/lib/ssl/sslimpl.h
+++ b/security/nss/lib/ssl/sslimpl.h
@@ -1265,6 +1265,10 @@ ssl_SetWrappingKey(SSLWrappedSymWrappingKey *wswk);
/* get rid of the symmetric wrapping key references. */
extern SECStatus SSL3_ShutdownServerCache(void);
+extern void ssl_InitClientSessionCacheLock(void);
+
+extern void ssl_InitSymWrapKeysLock(void);
+
/********************** misc calls *********************/
extern int ssl_MapLowLevelError(int hiLevelError);
diff --git a/security/nss/lib/ssl/sslnonce.c b/security/nss/lib/ssl/sslnonce.c
index dc27d8f5f..3e5ed37a6 100644
--- a/security/nss/lib/ssl/sslnonce.c
+++ b/security/nss/lib/ssl/sslnonce.c
@@ -54,8 +54,8 @@
PRUint32 ssl_sid_timeout = 100;
PRUint32 ssl3_sid_timeout = 86400L; /* 24 hours */
-static sslSessionID *cache;
-static PZLock * cacheLock;
+static sslSessionID *cache = NULL;
+static PZLock * cacheLock = NULL;
/* sids can be in one of 4 states:
*
@@ -68,14 +68,16 @@ static PZLock * cacheLock;
#define LOCK_CACHE lock_cache()
#define UNLOCK_CACHE PZ_Unlock(cacheLock)
-static void
-lock_cache(void)
+void ssl_InitClientSessionCacheLock(void)
{
- /* XXX Since the client session cache has no init function, we must
- * XXX init the cacheLock on the first call. Fix in NSS 3.0.
- */
if (!cacheLock)
nss_InitLock(&cacheLock, nssILockCache);
+}
+
+static void
+lock_cache(void)
+{
+ ssl_InitClientSessionCacheLock();
PZ_Lock(cacheLock);
}
diff --git a/security/nss/lib/ssl/sslsnce.c b/security/nss/lib/ssl/sslsnce.c
index 0d8413e18..3e73b2e6a 100644
--- a/security/nss/lib/ssl/sslsnce.c
+++ b/security/nss/lib/ssl/sslsnce.c
@@ -1172,6 +1172,8 @@ SSL_ConfigServerSessionIDCache( int maxCacheEntries,
PRUint32 ssl3_timeout,
const char * directory)
{
+ ssl_InitClientSessionCacheLock();
+ ssl_InitSymWrapKeysLock();
return SSL_ConfigServerSessionIDCacheInstance(&globalCache,
maxCacheEntries, ssl2_timeout, ssl3_timeout, directory, PR_FALSE);
}
@@ -1279,6 +1281,10 @@ SSL_InheritMPServerSIDCacheInstance(cacheDesc *cache, const char * envString)
}
return SECSuccess; /* already done. */
}
+
+ ssl_InitClientSessionCacheLock();
+ ssl_InitSymWrapKeysLock();
+
ssl_sid_lookup = ServerSessionIDLookup;
ssl_sid_cache = ServerSessionIDCache;
ssl_sid_uncache = ServerSessionIDUncache;