From f0ede6807153e84fe05a612ac00380334200cfc5 Mon Sep 17 00:00:00 2001 From: Etienne Carriere Date: Fri, 2 Aug 2024 08:47:21 +0200 Subject: [PATCH] xtest: pkcs11: fix test_find_objects() when wrong count Fix test_find_objects() so that C_FindObjectsFinal() is properly called even if we don't find the expected number of objects. Fixes: afe2b54fb68b ("xtest: pkcs11: add find object tests") Signed-off-by: Etienne Carriere Reviewed-by: Jerome Forissier --- host/xtest/pkcs11_1000.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/host/xtest/pkcs11_1000.c b/host/xtest/pkcs11_1000.c index 07fc04499..87739e8c0 100644 --- a/host/xtest/pkcs11_1000.c +++ b/host/xtest/pkcs11_1000.c @@ -2622,23 +2622,25 @@ static CK_RV test_find_objects(ADBG_Case_t *c, CK_SESSION_HANDLE session, CK_ULONG expected_cnt) { CK_RV rv = CKR_GENERAL_ERROR; + CK_RV rv2 = CKR_GENERAL_ERROR; CK_ULONG hdl_count = 0; rv = C_FindObjectsInit(session, find_template, attr_count); if (!ADBG_EXPECT_CK_OK(c, rv)) return rv; - rv = C_FindObjects(session, obj_found, obj_count, &hdl_count); - if (!ADBG_EXPECT_CK_OK(c, rv)) - return rv; - if (!ADBG_EXPECT_COMPARE_UNSIGNED(c, hdl_count, ==, expected_cnt)) - return CKR_GENERAL_ERROR; + rv2 = C_FindObjects(session, obj_found, obj_count, &hdl_count); + if (ADBG_EXPECT_CK_OK(c, rv2)) { + if (!ADBG_EXPECT_COMPARE_UNSIGNED(c, hdl_count, ==, + expected_cnt)) + rv2 = CKR_GENERAL_ERROR; + } rv = C_FindObjectsFinal(session); if (!ADBG_EXPECT_CK_OK(c, rv)) return rv; - return rv; + return rv2; } static void destroy_persistent_objects(ADBG_Case_t *c, CK_SLOT_ID slot)