Skip to content

Commit

Permalink
xtest: pkcs11: fix test_find_objects() when wrong count
Browse files Browse the repository at this point in the history
Fix test_find_objects() so that C_FindObjectsFinal() is properly called
even if we don't find the expected number of objects.

Fixes: afe2b54 ("xtest: pkcs11: add find object tests")
Signed-off-by: Etienne Carriere <etienne.carriere@foss.st.com>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
  • Loading branch information
etienne-lms authored and jforissier committed Sep 9, 2024
1 parent dd5692a commit b753522
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions host/xtest/pkcs11_1000.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b753522

Please sign in to comment.