Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/lib/SoftHSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2314,6 +2314,9 @@ CK_RV SoftHSM::C_FindObjectsInit(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pT
{
if (attr.isByteStringAttribute())
{
// A value without a buffer matches nothing, as above
if (pTemplate[i].ulValueLen != 0 && pTemplate[i].pValue == NULL_PTR)
break;
ByteString bsAttrValue;
if (isPrivateObject && attr.getByteStringValue().size() != 0)
{
Expand Down
14 changes: 14 additions & 0 deletions src/lib/test/ObjectTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,20 @@ void ObjectTests::testFindObjects()
CPPUNIT_ASSERT_EQUAL(CKR_OK, rv);
CPPUNIT_ASSERT(2 == ulObjectCount);
rv = CRYPTOKI_F_PTR( C_FindObjectsFinal(hSessionRW) );

// Issue #904: a byte string value with a length but no buffer matches
// nothing, and must not be read, even when an object has a value of
// that length
CK_ATTRIBUTE nullValue[] = {
{ CKA_LABEL, NULL_PTR, strlen(pLabel) }
};
rv = CRYPTOKI_F_PTR( C_FindObjectsInit(hSessionRW,&nullValue[0],1) );
CPPUNIT_ASSERT_EQUAL(CKR_OK, rv);
rv = CRYPTOKI_F_PTR( C_FindObjects(hSessionRW,&hObjects[0],16,&ulObjectCount) );
CPPUNIT_ASSERT_EQUAL(CKR_OK, rv);
CPPUNIT_ASSERT(0 == ulObjectCount);
rv = CRYPTOKI_F_PTR( C_FindObjectsFinal(hSessionRW) );
CPPUNIT_ASSERT_EQUAL(CKR_OK, rv);
}


Expand Down
Loading