From 1d2a53b9557bd0b3a10543ded33590f4d3bcbd08 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 8 Oct 2024 09:47:01 -0400 Subject: [PATCH] Ensure pools are consistent when we store objects This was broken by a recent commit as slotid is populated when a mock object is actually stored in the session, but the object was not added to the pool, leading the code that frees object to complain the pool was in an inconsistent state because the object could not be found there. Signed-off-by: Simo Sorce --- src/objects.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/objects.c b/src/objects.c index b8d55c34..0ee7fe61 100644 --- a/src/objects.c +++ b/src/objects.c @@ -3315,6 +3315,12 @@ static CK_RV p11prov_obj_store_public_key(P11PROV_OBJ *key) rv = CKR_GENERAL_ERROR; } + if (rv == CKR_OK) { + /* this is a real object now, add it to the pool, but do not + * fail if the operation goes haywire for some reason */ + (void)obj_add_to_pool(key); + } + return rv; }