Blame SOURCES/0010-p11sak-Fix-segfault-when-dilithium-version-is-not-sp.patch

971d89
From bea2552c40339d9013eaaa55b13491c7e36fbadf Mon Sep 17 00:00:00 2001
971d89
From: Ingo Franzki <ifranzki@linux.ibm.com>
971d89
Date: Tue, 8 Nov 2022 15:49:22 +0100
971d89
Subject: [PATCH 10/34] p11sak: Fix segfault when dilithium version is not
971d89
 specified with generate-key
971d89
971d89
Command 'p11sak generate-key ibm-dilithium' segfaults because the dilithium
971d89
version is not specified, but the code does not check for a NULL pointer.
971d89
971d89
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
971d89
---
971d89
 usr/sbin/p11sak/p11sak.c | 6 ++++++
971d89
 1 file changed, 6 insertions(+)
971d89
971d89
diff --git a/usr/sbin/p11sak/p11sak.c b/usr/sbin/p11sak/p11sak.c
971d89
index b399c88a..8cfcb21d 100644
971d89
--- a/usr/sbin/p11sak/p11sak.c
971d89
+++ b/usr/sbin/p11sak/p11sak.c
971d89
@@ -1843,6 +1843,12 @@ static CK_RV check_args_gen_key(p11sak_kt *kt, CK_ULONG keylength,
971d89
     case kt_3DES:
971d89
         break;
971d89
     case kt_IBM_DILITHIUM:
971d89
+        if (dilithium_ver == NULL) {
971d89
+            fprintf(stderr,
971d89
+                    "Cipher key type [%d] supported but Dilithium version not set in arguments. Try adding argument <r2_65>\n",
971d89
+                    *kt);
971d89
+            return CKR_ARGUMENTS_BAD;
971d89
+        }
971d89
         if (strcasecmp(dilithium_ver, "r2_65") == 0) {
971d89
             break;
971d89
         } else {
971d89
-- 
971d89
2.16.2.windows.1
971d89