pkcs11-provider/0001-utils-Handle-correctly-CK_UNAVAILABLE_INFORMATION-wh.patch
Simo Sorce 6a4694191f Backport upstream fixes
Resolves: RHEL-82708

Signed-off-by: Simo Sorce <simo@redhat.com>
2025-03-11 14:16:10 -04:00

35 lines
1.3 KiB
Diff

From 02dc73fd441f9f87bd237a1fbd0a7cab9d948cbe Mon Sep 17 00:00:00 2001
From: Jakub Jelen <jjelen@redhat.com>
Date: Mon, 3 Mar 2025 17:10:17 +0100
Subject: [PATCH] utils: Handle correctly CK_UNAVAILABLE_INFORMATION when
reading attributes
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
---
src/util.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/util.c b/src/util.c
index a956f9d..bb1a389 100644
--- a/src/util.c
+++ b/src/util.c
@@ -84,8 +84,13 @@ CK_RV p11prov_fetch_attributes(P11PROV_CTX *ctx, P11PROV_SESSION *session,
return ret;
}
} else {
- attrs[i].attr.pValue =
- OPENSSL_zalloc(attrs[i].attr.ulValueLen + 1);
+ CK_ULONG len = attrs[i].attr.ulValueLen;
+ if (len == CK_UNAVAILABLE_INFORMATION) {
+ /* The attribute is known to the module, but not
+ * available on this object */
+ continue;
+ }
+ attrs[i].attr.pValue = OPENSSL_zalloc(len + 1);
if (!attrs[i].attr.pValue) {
ret = CKR_HOST_MEMORY;
P11PROV_raise(ctx, ret, "Failed to get attributes");
--
2.48.1