bug 174200, don't attempt to decode cert when destroying it, handle failure
to decode cert serial number r=nelsonb git-svn-id: svn://10.0.0.236/trunk@137945 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
f1a58a1ae6
commit
e26258fd38
@ -593,33 +593,19 @@ loser:
|
||||
void
|
||||
CERT_DestroyCertificate(CERTCertificate *cert)
|
||||
{
|
||||
int refCount;
|
||||
CERTCertDBHandle *handle;
|
||||
if ( cert ) {
|
||||
NSSCertificate *tmp = STAN_GetNSSCertificate(cert);
|
||||
handle = cert->dbhandle;
|
||||
#ifdef NSS_CLASSIC
|
||||
CERT_LockCertRefCount(cert);
|
||||
PORT_Assert(cert->referenceCount > 0);
|
||||
refCount = --cert->referenceCount;
|
||||
CERT_UnlockCertRefCount(cert);
|
||||
if ( ( refCount == 0 ) && !cert->keepSession ) {
|
||||
PRArenaPool *arena = cert->arena;
|
||||
/* zero cert before freeing. Any stale references to this cert
|
||||
* after this point will probably cause an exception. */
|
||||
PORT_Memset(cert, 0, sizeof *cert);
|
||||
cert = NULL;
|
||||
/* free the arena that contains the cert. */
|
||||
PORT_FreeArena(arena, PR_FALSE);
|
||||
}
|
||||
#else
|
||||
/* don't use STAN_GetNSSCertificate because we don't want to
|
||||
* go to the trouble of translating the CERTCertificate into
|
||||
* an NSSCertificate just to destroy it. If it hasn't been done
|
||||
* yet, don't do it at all.
|
||||
*/
|
||||
NSSCertificate *tmp = cert->nssCertificate;
|
||||
if (tmp) {
|
||||
/* delete the NSSCertificate */
|
||||
NSSCertificate_Destroy(tmp);
|
||||
} else {
|
||||
PORT_FreeArena(cert->arena, PR_FALSE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
static const char CVS_ID[] = "@(#) $RCSfile: pki3hack.c,v $ $Revision: 1.73 $ $Date: 2003-01-08 21:48:43 $ $Name: not supported by cvs2svn $";
|
||||
static const char CVS_ID[] = "@(#) $RCSfile: pki3hack.c,v $ $Revision: 1.74 $ $Date: 2003-02-18 20:53:14 $ $Name: not supported by cvs2svn $";
|
||||
#endif /* DEBUG */
|
||||
|
||||
/*
|
||||
@ -806,7 +806,12 @@ STAN_GetNSSCertificate(CERTCertificate *cc)
|
||||
* here. sigh.
|
||||
*/
|
||||
SECItem derSerial;
|
||||
CERT_SerialNumberFromDERCert(&cc->derCert, &derSerial);
|
||||
SECStatus secrv;
|
||||
secrv = CERT_SerialNumberFromDERCert(&cc->derCert, &derSerial);
|
||||
if (secrv == SECFailure) {
|
||||
nssArena_Destroy(arena);
|
||||
return NULL;
|
||||
}
|
||||
nssItem_Create(arena, &c->serial, derSerial.len, derSerial.data);
|
||||
PORT_Free(derSerial.data);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user