Index: cackey.c ================================================================== --- cackey.c +++ cackey.c @@ -2512,10 +2512,19 @@ pValue = &ck_true; ulValueLen = sizeof(ck_true); CACKEY_DEBUG_PRINTF(" ... returning %lu (%p/%lu)", (unsigned long) *((CK_BBOOL *) pValue), pValue, (unsigned long) ulValueLen); + break; + case CKA_TRUSTED: + CACKEY_DEBUG_PRINTF("Requesting attribute CKA_TRUSTED (0x%08lx) ...", (unsigned long) curr_attr_type); + + pValue = &ck_true; + ulValueLen = sizeof(ck_true); + + CACKEY_DEBUG_PRINTF(" ... returning %lu (%p/%lu)", (unsigned long) *((CK_BBOOL *) pValue), pValue, (unsigned long) ulValueLen); + break; case CKA_MODIFIABLE: CACKEY_DEBUG_PRINTF("Requesting attribute CKA_MODIFIABLE (0x%08lx) ...", (unsigned long) curr_attr_type); pValue = &ck_false; @@ -4260,10 +4269,11 @@ return(CKR_FUNCTION_NOT_SUPPORTED); } CK_DEFINE_FUNCTION(CK_RV, C_FindObjectsInit)(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount) { CK_SLOT_ID slotID; + CK_ULONG idx; int mutex_retval; CACKEY_DEBUG_PRINTF("Called."); if (!cackey_initialized) { @@ -4344,10 +4354,23 @@ if (ulCount != 0) { cackey_sessions[hSession].search_query_count = ulCount; cackey_sessions[hSession].search_query = malloc(ulCount * sizeof(*pTemplate)); memcpy(cackey_sessions[hSession].search_query, pTemplate, ulCount * sizeof(*pTemplate)); + for (idx = 0; idx < ulCount; idx++) { + if (pTemplate[idx].ulValueLen == 0) { + cackey_sessions[hSession].search_query[idx].pValue = NULL; + + continue; + } + + cackey_sessions[hSession].search_query[idx].pValue = malloc(pTemplate[idx].ulValueLen); + + if (cackey_sessions[hSession].search_query[idx].pValue) { + memcpy(cackey_sessions[hSession].search_query[idx].pValue, pTemplate[idx].pValue, pTemplate[idx].ulValueLen); + } + } } else { cackey_sessions[hSession].search_query_count = 0; cackey_sessions[hSession].search_query = NULL; } } else { @@ -4520,10 +4543,11 @@ return(CKR_OK); } CK_DEFINE_FUNCTION(CK_RV, C_FindObjectsFinal)(CK_SESSION_HANDLE hSession) { + CK_ULONG idx; int mutex_retval; CACKEY_DEBUG_PRINTF("Called."); if (!cackey_initialized) { @@ -4560,10 +4584,17 @@ return(CKR_OPERATION_NOT_INITIALIZED); } cackey_sessions[hSession].search_active = 0; + + for (idx = 0; idx < cackey_sessions[hSession].search_query_count; idx++) { + if (cackey_sessions[hSession].search_query[idx].pValue) { + free(cackey_sessions[hSession].search_query[idx].pValue); + } + } + if (cackey_sessions[hSession].search_query) { free(cackey_sessions[hSession].search_query); } mutex_retval = cackey_mutex_unlock(cackey_biglock);