Fix attached.
From 3a1ef233ec8e63e5ec34cd0746cd5e94e327c65f Mon Sep 17 00:00:00 2001
From: Jack Magne <jma...@dhcp-16-206.sjc.redhat.com>
Date: Mon, 6 Jun 2016 16:36:16 -0700
Subject: [PATCH] Fix coverity warnings for 'tkstool'

Issues listed in the ticket addressed by this patch.

Ticket #1199 : Fix coverity warnings for 'tkstool'.
---
 base/native-tools/src/tkstool/secutil.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/base/native-tools/src/tkstool/secutil.c b/base/native-tools/src/tkstool/secutil.c
index 9cf2c37..c31ce9b 100644
--- a/base/native-tools/src/tkstool/secutil.c
+++ b/base/native-tools/src/tkstool/secutil.c
@@ -668,7 +668,7 @@ SECU_ReadDERFromFile(SECItem *der, PRFileDesc *inFile, PRBool ascii)
     SECStatus rv;
     if (ascii) {
 	/* First convert ascii to binary */
-	SECItem filedata;
+	SECItem filedata = {siBuffer,0};
 	char *asc, *body;
 
 	/* Read in ascii data */
@@ -1419,7 +1419,7 @@ SECU_PrintAlgorithmID(FILE *out, SECAlgorithmID *a, char *m, int level)
 {
     SECU_PrintObjectID(out, &a->algorithm, m, level);
 
-    if (a->parameters.len == 0
+    if (a == NULL || a->parameters.len == 0
 	|| (a->parameters.len == 2
 	    && PORT_Memcmp(a->parameters.data, "\005\000", 2) == 0)) {
 	/* No arguments or NULL argument */
@@ -2471,6 +2471,10 @@ static void
 secu_PrintPKCS7EncContent(FILE *out, SEC_PKCS7EncryptedContentInfo *src, 
 			  char *m, int level)
 {
+    if (src == NULL) {
+        fprintf(out,"Invalid input to secu_PrintPKCS7EncContent!\n");
+        return;
+    }
     if (src->contentTypeTag == NULL)
 	src->contentTypeTag = SECOID_FindOID(&(src->contentType));
 
@@ -3074,16 +3078,23 @@ SECU_ParseCommandLine(int argc, char **argv, char *progName, secuCommand *cmd)
 		if (optstate->value) {
 		    cmd->options[i].arg = (char *)optstate->value;
 		} else if (cmd->options[i].needsArg) {
-                    return SECFailure;
+                    status = PL_OPT_BAD;
+                    goto done;
                 }
 		found = PR_TRUE;
 		break;
 	    }
 	}
 
-	if (!found)
-	    return SECFailure;
+	if (!found) {
+            status = PL_OPT_BAD;
+            goto done;
+        }
     }
+done:
+
+    if (optstring != NULL)
+        free(optstring);
     if (status == PL_OPT_BAD)
 	return SECFailure;
     return SECSuccess;
-- 
2.5.0

_______________________________________________
Pki-devel mailing list
Pki-devel@redhat.com
https://www.redhat.com/mailman/listinfo/pki-devel

Reply via email to