diff options
author | wtchang%redhat.com <devnull@localhost> | 2006-12-06 21:50:40 +0000 |
---|---|---|
committer | wtchang%redhat.com <devnull@localhost> | 2006-12-06 21:50:40 +0000 |
commit | 64f7f446162786efa2d82049405a99358ad32c6f (patch) | |
tree | 0fd56672138faff7dd2d09f08ede18bb8c861161 | |
parent | 82d29ca6263e0412f3e2847c58e27f7f770ef679 (diff) | |
download | nss-hg-64f7f446162786efa2d82049405a99358ad32c6f.tar.gz |
Bugzilla Bug 342795: the call-once functions need to store the error code
on failure so that the error code can be retrieved later. r=nelsonb and
alexei.volkov.
-rw-r--r-- | security/nss/lib/ssl/ssl3ecc.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/security/nss/lib/ssl/ssl3ecc.c b/security/nss/lib/ssl/ssl3ecc.c index 9f89f804c..9262634d2 100644 --- a/security/nss/lib/ssl/ssl3ecc.c +++ b/security/nss/lib/ssl/ssl3ecc.c @@ -222,7 +222,7 @@ static const Bits2Curve bits2curve [] = { typedef struct ECDHEKeyPairStr { ssl3KeyPair * pair; - PRInt32 flag; + int error; /* error code of the call-once function */ PRCallOnceType once; } ECDHEKeyPair; @@ -550,9 +550,12 @@ ssl3_ShutdownECDHECurves(void *appData, void *nssData) static PRStatus ssl3_ECRegister(void) { - SECStatus rv; - rv = NSS_RegisterShutdown(ssl3_ShutdownECDHECurves, gECDHEKeyPairs); - return (PRStatus)rv; + SECStatus rv; + rv = NSS_RegisterShutdown(ssl3_ShutdownECDHECurves, gECDHEKeyPairs); + if (rv != SECSuccess) { + gECDHEKeyPairs[ec_noName].error = PORT_GetError(); + } + return (PRStatus)rv; } /* CallOnce function, called once for each named curve. */ @@ -569,6 +572,7 @@ ssl3_CreateECDHEphemeralKeyPair(void * arg) /* ok, no one has generated a global key for this curve yet, do so */ if (ecName2params(NULL, ec_curve, &ecParams) != SECSuccess) { + gECDHEKeyPairs[ec_curve].error = PORT_GetError(); return PR_FAILURE; } @@ -583,6 +587,7 @@ ssl3_CreateECDHEphemeralKeyPair(void * arg) SECKEY_DestroyPublicKey(pubKey); } ssl_MapLowLevelError(SEC_ERROR_KEYGEN_FAIL); + gECDHEKeyPairs[ec_curve].error = PORT_GetError(); return PR_FAILURE; } @@ -610,12 +615,14 @@ ssl3_CreateECDHEphemeralKeys(sslSocket *ss, ECName ec_curve) status = PR_CallOnce(&gECDHEKeyPairs[ec_noName].once, ssl3_ECRegister); if (status != PR_SUCCESS) { + PORT_SetError(gECDHEKeyPairs[ec_noName].error); return SECFailure; } status = PR_CallOnceWithArg(&gECDHEKeyPairs[ec_curve].once, ssl3_CreateECDHEphemeralKeyPair, (void *)ec_curve); if (status != PR_SUCCESS) { + PORT_SetError(gECDHEKeyPairs[ec_curve].error); return SECFailure; } } |