CERT_ImportCerts now returns SECFailure when NONE of the certs was succesfully imported. r=wtc. Bugscape bug 54311.
authornelsonb%netscape.com
Sat, 06 Dec 2003 06:52:53 +0000
changeset 4920 6377ea8d364304b41904f87099b708cb33b232e4
parent 4919 c772c03f94917fca65f2a8f5b491efa1483eb4f3
child 4921 707967bcd95ce2c088e7f6c796d277b38132439d
child 4925 619d0e2a18f801d5498c43e734133c57ec461340
push idunknown
push userunknown
push dateunknown
reviewerswtc
bugs54311
CERT_ImportCerts now returns SECFailure when NONE of the certs was succesfully imported. r=wtc. Bugscape bug 54311.
security/nss/lib/certdb/certdb.c
--- a/security/nss/lib/certdb/certdb.c
+++ b/security/nss/lib/certdb/certdb.c
@@ -2240,17 +2240,17 @@ CERT_ImportCerts(CERTCertDBHandle *certd
 		 PRBool caOnly, char *nickname)
 {
     unsigned int i;
     CERTCertificate **certs = NULL;
     SECStatus rv;
     unsigned int fcerts = 0;
 
     if ( ncerts ) {
-	certs = (CERTCertificate**)PORT_ZAlloc(sizeof(CERTCertificate *) * ncerts );
+	certs = PORT_ZNewArray(CERTCertificate*, ncerts);
 	if ( certs == NULL ) {
 	    return(SECFailure);
 	}
     
 	/* decode all of the certs into the temporary DB */
 	for ( i = 0, fcerts= 0; i < ncerts; i++) {
 	    certs[fcerts] = CERT_NewTempCertificate(certdb,
 	                                            derCerts[i],
@@ -2301,28 +2301,17 @@ CERT_ImportCerts(CERTCertDBHandle *certd
     if ( retCerts ) {
 	*retCerts = certs;
     } else {
 	if (certs) {
 	    CERT_DestroyCertArray(certs, fcerts);
 	}
     }
 
-    return(SECSuccess);
-    
-#if 0	/* dead code here - why ?? XXX */
-loser:
-    if ( retCerts ) {
-	*retCerts = NULL;
-    }
-    if ( certs ) {
-	CERT_DestroyCertArray(certs, ncerts);
-    }    
-    return(SECFailure);
-#endif
+    return (fcerts ? SECSuccess : SECFailure);
 }
 
 /*
  * a real list of certificates - need to convert CERTCertificateList
  * stuff and ASN 1 encoder/decoder over to using this...
  */
 CERTCertList *
 CERT_NewCertList(void)