Hello Opencryptoki developers,

from the latest build for RHEL7 (with several patches on top of 3.5 release) jumped again few new notes from Coverity about unchecked return values from various functions. It is probably low priority, but it would be nice to check these values, since you do that already in all the other cases. See attached patch which should fix these warnings.

Kind regards,

--
Jakub Jelen
Associate Software Engineer
Security Technologies
Red Hat

>From 08201aa4fed814b2afab723ff1cd8d24aafeeed2 Mon Sep 17 00:00:00 2001
From: Jakub Jelen <[email protected]>
Date: Tue, 28 Jun 2016 12:57:18 +0200
Subject: [PATCH] Coverity: NULL_RETURNS: Should check against NULL as in all
 the other cases

---
 usr/lib/pkcs11/common/utility.c      |  5 +++++
 usr/lib/pkcs11/icsf_stdll/new_host.c | 10 ++++++++++
 2 files changed, 15 insertions(+)

diff --git a/usr/lib/pkcs11/common/utility.c b/usr/lib/pkcs11/common/utility.c
index 3cbb8da..39ecae8 100755
--- a/usr/lib/pkcs11/common/utility.c
+++ b/usr/lib/pkcs11/common/utility.c
@@ -589,6 +589,11 @@ CK_RV CreateXProcLock(void)
 				goto err;
 			}
 			grp = getgrnam("pkcs11");
+			if (grp == NULL) {
+				fprintf(stderr, "getgrname(pkcs11): %s",
+					strerror(errno));
+				goto err;
+			}
 			/* set ownership to euid, and pkcs11 group */
 			if (chown(lockdir, geteuid(), grp->gr_gid) != 0) {
 				fprintf(stderr, "Failed to set owner:group \
diff --git a/usr/lib/pkcs11/icsf_stdll/new_host.c b/usr/lib/pkcs11/icsf_stdll/new_host.c
index 9863d52..9478e92 100644
--- a/usr/lib/pkcs11/icsf_stdll/new_host.c
+++ b/usr/lib/pkcs11/icsf_stdll/new_host.c
@@ -813,6 +813,11 @@ CK_RV SC_OpenSession(CK_SLOT_ID sid, CK_FLAGS flags,
 	}
 
 	sess = session_mgr_find(*phSession);
+	if (!sess) {
+		TRACE_ERROR("%s\n", ock_err(ERR_SESSION_HANDLE_INVALID));
+		rc = CKR_SESSION_HANDLE_INVALID;
+		goto done;
+	}
 	sess->handle = *phSession;
 	rc = icsftok_open_session(sess);
 done:
@@ -835,6 +840,11 @@ CK_RV SC_CloseSession(ST_SESSION_HANDLE *sSession)
 	}
 
 	sess = session_mgr_find(sSession->sessionh);
+	if (!sess) {
+		TRACE_ERROR("%s\n", ock_err(ERR_SESSION_HANDLE_INVALID));
+		rc = CKR_SESSION_HANDLE_INVALID;
+		goto done;
+	}
 	//set the handle here as handle is never set into session during creation
 	sess->handle = sSession->sessionh;
 	rc = icsftok_close_session(sess);
-- 
2.5.5

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
Opencryptoki-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opencryptoki-tech

Reply via email to