Skip to content

Commit

Permalink
Fix for C_GetAttributeValue incorrectly erroring with `CKR_ATTRIBUT…
Browse files Browse the repository at this point in the history
…E_VALUE_INVALID` when data == NULL. The `C_GetAttributeValue` should set length if data field is NULL.
  • Loading branch information
dgarske committed Jan 9, 2024
1 parent c9ccc51 commit 9afc2d3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ static CK_RV CheckAttributes(CK_ATTRIBUTE* pTemplate, CK_ULONG ulCount, int set)
return CKR_ATTRIBUTE_TYPE_INVALID;

if (attrType[j].type == ATTR_TYPE_ULONG) {
if (attr->pValue == NULL)
if (attr->pValue == NULL && set)
return CKR_ATTRIBUTE_VALUE_INVALID;
if (attr->ulValueLen != sizeof(CK_ULONG))
return CKR_BUFFER_TOO_SMALL;
}
else if (attrType[j].type == ATTR_TYPE_BOOL) {
if (attr->pValue == NULL)
if (attr->pValue == NULL && set)
return CKR_ATTRIBUTE_VALUE_INVALID;
if (attr->ulValueLen != sizeof(CK_BBOOL))
return CKR_BUFFER_TOO_SMALL;
Expand All @@ -259,7 +259,7 @@ static CK_RV CheckAttributes(CK_ATTRIBUTE* pTemplate, CK_ULONG ulCount, int set)
}
}
else if (attrType[j].type == ATTR_TYPE_DATE) {
if (attr->pValue == NULL)
if (attr->pValue == NULL && set)
return CKR_ATTRIBUTE_VALUE_INVALID;
if (attr->ulValueLen != sizeof(CK_DATE))
return CKR_BUFFER_TOO_SMALL;
Expand Down

0 comments on commit 9afc2d3

Please sign in to comment.