From 4d505107eb4577eb5d7567a27e2d01b3eb3ce53e Mon Sep 17 00:00:00 2001 From: "wenxin.leong" Date: Mon, 22 Apr 2024 13:33:02 +0800 Subject: [PATCH] C_CreateObject should not return CKR_SESSION_READ_ONLY when a RW session is in use. Signed-off-by: wenxin.leong --- src/lib/object.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/lib/object.c b/src/lib/object.c index 9a3faba6..5564a5de 100644 --- a/src/lib/object.c +++ b/src/lib/object.c @@ -1123,12 +1123,14 @@ CK_RV object_create(session_ctx *ctx, CK_ATTRIBUTE *templ, CK_ULONG count, CK_OB /* * Currently we only support RW user session state objects. */ - if (state != CKS_RW_USER_FUNCTIONS) { - if (state == CKS_RW_SO_FUNCTIONS) { - return CKR_USER_NOT_LOGGED_IN; - } else { - return CKR_SESSION_READ_ONLY; - } + switch(state) { + case CKS_RW_USER_FUNCTIONS: + break; + case CKS_RW_PUBLIC_SESSION: + case CKS_RW_SO_FUNCTIONS: + return CKR_USER_NOT_LOGGED_IN; + default: + return CKR_SESSION_READ_ONLY; } /*