Blame SOURCES/0021-clang-Garbage-value-possible.patch

398fc5
From 3727376f8654f9e1dd88b1f9721124f9fc96ad0a Mon Sep 17 00:00:00 2001
398fc5
From: Rob Crittenden <rcritten@redhat.com>
398fc5
Date: Mon, 8 Oct 2018 14:44:05 -0400
398fc5
Subject: [PATCH 21/25] clang: Garbage value possible
398fc5
398fc5
Need to add guard so that error was only considered if the
398fc5
certificate was decodable and an import was attempted.
398fc5
---
398fc5
 src/certsave-n.c | 4 +++-
398fc5
 1 file changed, 3 insertions(+), 1 deletion(-)
398fc5
398fc5
diff --git a/src/certsave-n.c b/src/certsave-n.c
398fc5
index 972a1dfa..30e242c1 100644
398fc5
--- a/src/certsave-n.c
398fc5
+++ b/src/certsave-n.c
398fc5
@@ -498,6 +498,7 @@ cm_certsave_n_main(int fd, struct cm_store_ca *ca, struct cm_store_entry *entry,
398fc5
 					}
398fc5
 				}
398fc5
 				/* Import the certificate. */
398fc5
+				error = SECFailure;
398fc5
 				newcert = CERT_DecodeCertFromPackage((char *)item->data, item->len);
398fc5
 				if (newcert != NULL) {
398fc5
 					error = PK11_ImportCert(sle->slot,
398fc5
@@ -506,7 +507,7 @@ cm_certsave_n_main(int fd, struct cm_store_ca *ca, struct cm_store_entry *entry,
398fc5
 						entry->cm_cert_nickname,
398fc5
 						PR_FALSE);
398fc5
 				}
398fc5
-				if (error == SECSuccess) {
398fc5
+				if ((newcert != NULL) && (error == SECSuccess)) {
398fc5
 					cm_log(1, "Imported certificate with "
398fc5
 					       "nickname \"%s\".\n",
398fc5
 					       entry->cm_cert_nickname);
398fc5
@@ -581,6 +582,7 @@ cm_certsave_n_main(int fd, struct cm_store_ca *ca, struct cm_store_entry *entry,
398fc5
 						CERT_DestroyCertList(certlist);
398fc5
 					}
398fc5
 				} else {
398fc5
+					ec = PORT_GetError();
398fc5
 					if (ec != 0) {
398fc5
 						es = PR_ErrorToName(ec);
398fc5
 					} else {
398fc5
-- 
398fc5
2.21.0
398fc5