diff options
author | wtchang%redhat.com <devnull@localhost> | 2005-06-30 20:53:57 +0000 |
---|---|---|
committer | wtchang%redhat.com <devnull@localhost> | 2005-06-30 20:53:57 +0000 |
commit | 04252937a62ccc3f81f1943a4f966e599fbd1020 (patch) | |
tree | c75803b6dd624749085bbf155875453b1d95433a /security/nss | |
parent | dcece24b4b767095eeb81b77a25e2676620ec41e (diff) | |
download | nss-hg-04252937a62ccc3f81f1943a4f966e599fbd1020.tar.gz |
Bugzilla Bug 287057: fixed memory leaks in callers of cert_FindExtension.
pass NULL as the SECItem* argument if we only want to know if the extension
exists but don't need its value. r=jpierre,nelsonb.
Modified Files:
certdb/certdb.c certdb/genname.c certhigh/certhigh.c
certhigh/certhtml.c certhigh/crlv2.c certhigh/ocsp.c
Diffstat (limited to 'security/nss')
-rw-r--r-- | security/nss/lib/certdb/certdb.c | 5 | ||||
-rw-r--r-- | security/nss/lib/certdb/genname.c | 2 | ||||
-rw-r--r-- | security/nss/lib/certhigh/certhigh.c | 8 | ||||
-rw-r--r-- | security/nss/lib/certhigh/certhtml.c | 15 | ||||
-rw-r--r-- | security/nss/lib/certhigh/crlv2.c | 5 | ||||
-rw-r--r-- | security/nss/lib/certhigh/ocsp.c | 7 |
6 files changed, 18 insertions, 24 deletions
diff --git a/security/nss/lib/certdb/certdb.c b/security/nss/lib/certdb/certdb.c index d7742d83c..1f2c91e17 100644 --- a/security/nss/lib/certdb/certdb.c +++ b/security/nss/lib/certdb/certdb.c @@ -545,6 +545,7 @@ cert_GetCertType(CERTCertificate *cert) tmpitem.data = NULL; CERT_FindNSCertTypeExtension(cert, &tmpitem); + encodedExtKeyUsage.data = NULL; rv = CERT_FindCertExtension(cert, SEC_OID_X509_EXT_KEY_USAGE, &encodedExtKeyUsage); if (rv == SECSuccess) { @@ -671,8 +672,10 @@ cert_GetCertType(CERTCertificate *cert) } } - if (extKeyUsage != NULL) { + if (encodedExtKeyUsage.data != NULL) { PORT_Free(encodedExtKeyUsage.data); + } + if (extKeyUsage != NULL) { CERT_DestroyOidSequence(extKeyUsage); } /* Assert that it is safe to cast &cert->nsCertType to "PRInt32 *" */ diff --git a/security/nss/lib/certdb/genname.c b/security/nss/lib/certdb/genname.c index 9c8d1a801..a5ac86e75 100644 --- a/security/nss/lib/certdb/genname.c +++ b/security/nss/lib/certdb/genname.c @@ -1462,6 +1462,7 @@ CERT_CompareNameSpace(CERTCertificate *cert, CERTNameConstraint *matchingConstraints; CERTCertificate *badCert = NULL; + constraintsExtension.data = NULL; rv = CERT_FindCertExtension(cert, SEC_OID_X509_NAME_CONSTRAINTS, &constraintsExtension); if (rv != SECSuccess) { @@ -1474,6 +1475,7 @@ CERT_CompareNameSpace(CERTCertificate *cert, } /* TODO: mark arena */ constraints = cert_DecodeNameConstraints(arena, &constraintsExtension); + PORT_Free(constraintsExtension.data); currentName = namesList; if (constraints == NULL) { /* decode failed */ rv = SECFailure; diff --git a/security/nss/lib/certhigh/certhigh.c b/security/nss/lib/certhigh/certhigh.c index 56e9695cd..2c0ffe7cb 100644 --- a/security/nss/lib/certhigh/certhigh.c +++ b/security/nss/lib/certhigh/certhigh.c @@ -743,6 +743,7 @@ CERT_FindCRLDistributionPoints (CERTCertificate *cert) { SECItem encodedExtenValue; SECStatus rv; + CERTCrlDistributionPoints *dps; encodedExtenValue.data = NULL; encodedExtenValue.len = 0; @@ -753,8 +754,11 @@ CERT_FindCRLDistributionPoints (CERTCertificate *cert) return (NULL); } - return (CERT_DecodeCRLDistributionPoints (cert->arena, - &encodedExtenValue)); + dps = CERT_DecodeCRLDistributionPoints(cert->arena, &encodedExtenValue); + + PORT_Free(encodedExtenValue.data); + + return dps; } /* From crl.c */ diff --git a/security/nss/lib/certhigh/certhtml.c b/security/nss/lib/certhigh/certhtml.c index f5ca082f8..11ce4f6c8 100644 --- a/security/nss/lib/certhigh/certhtml.c +++ b/security/nss/lib/certhigh/certhtml.c @@ -407,7 +407,6 @@ CERT_HTMLCertInfo(CERTCertificate *cert, PRBool showImages, PRBool showIssuer) char *notBefore, *notAfter; char *ret; char *nickname; - SECItem dummyitem; unsigned char fingerprint[16]; /* result of MD5, always 16 bytes */ char *fpstr; SECItem fpitem; @@ -435,12 +434,8 @@ CERT_HTMLCertInfo(CERTCertificate *cert, PRBool showImages, PRBool showIssuer) showImages = PR_FALSE; } - dummyitem.data = NULL; rv = CERT_FindCertExtension(cert, SEC_OID_NS_CERT_EXT_SUBJECT_LOGO, - &dummyitem); - if ( dummyitem.data ) { - PORT_Free(dummyitem.data); - } + NULL); if ( rv || !showImages ) { htmlcertstrings[1] = ""; @@ -468,13 +463,8 @@ CERT_HTMLCertInfo(CERTCertificate *cert, PRBool showImages, PRBool showIssuer) htmlcertstrings[5] = subject; - dummyitem.data = NULL; - rv = CERT_FindCertExtension(cert, SEC_OID_NS_CERT_EXT_ISSUER_LOGO, - &dummyitem); - if ( dummyitem.data ) { - PORT_Free(dummyitem.data); - } + NULL); if ( rv || !showImages ) { htmlcertstrings[7] = ""; @@ -500,6 +490,7 @@ CERT_HTMLCertInfo(CERTCertificate *cert, PRBool showImages, PRBool showIssuer) pubk = CERT_ExtractPublicKey(cert); DSSPriv = NULL; if (pubk && (pubk->keyType == fortezzaKey)) { + SECItem dummyitem; htmlcertstrings[18] = "</b><br><b>Clearance:</b>"; htmlcertstrings[19] = sec_FortezzaClearance( &pubk->u.fortezza.clearance); diff --git a/security/nss/lib/certhigh/crlv2.c b/security/nss/lib/certhigh/crlv2.c index 3e9e0e44e..b6d8c9182 100644 --- a/security/nss/lib/certhigh/crlv2.c +++ b/security/nss/lib/certhigh/crlv2.c @@ -133,9 +133,8 @@ SECStatus CERT_FindInvalidDateExten (CERTCrl *crl, int64 *value) rv = SEC_ASN1DecodeItem (NULL, &decodedExtenValue, SEC_GeneralizedTimeTemplate, &encodedExtenValue); - if (rv != SECSuccess) - return (rv); - rv = DER_GeneralizedTimeToTime(value, &encodedExtenValue); + if (rv == SECSuccess) + rv = DER_GeneralizedTimeToTime(value, &encodedExtenValue); PORT_Free (decodedExtenValue.data); PORT_Free (encodedExtenValue.data); return (rv); diff --git a/security/nss/lib/certhigh/ocsp.c b/security/nss/lib/certhigh/ocsp.c index 54fa8ca24..9eda390b4 100644 --- a/security/nss/lib/certhigh/ocsp.c +++ b/security/nss/lib/certhigh/ocsp.c @@ -2296,14 +2296,9 @@ static PRBool ocsp_CertHasNoCheckExtension(CERTCertificate *cert) { SECStatus rv; - SECItem extItem; - extItem.data = NULL; rv = CERT_FindCertExtension(cert, SEC_OID_PKIX_OCSP_NO_CHECK, - &extItem); - if (extItem.data != NULL) { - PORT_Free(extItem.data); - } + NULL); if (rv == SECSuccess) { return PR_TRUE; } |