Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Zoltan Fridrich <[email protected]>
  • Loading branch information
ZoltanFridrich committed Mar 5, 2024
1 parent 697792a commit 719f31b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions common/mock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,8 @@ get_recursive_attribute_value (CK_ATTRIBUTE_PTR dest,
result = dest + i;
attr = src + i;

result->type = attr->type;

if (result->pValue == NULL) {
result->ulValueLen = attr->ulValueLen;
continue;
Expand Down
17 changes: 10 additions & 7 deletions p11-kit/iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1013,8 +1013,8 @@ p11_kit_iter_get_attributes (P11KitIter *iter,
}

static CK_RV
load_recursive_attribute (P11KitIter *iter,
CK_ATTRIBUTE *templ)
prepare_recursive_attribute (P11KitIter *iter,
CK_ATTRIBUTE *templ)
{
CK_RV rv;
CK_ULONG count, i;
Expand All @@ -1033,7 +1033,6 @@ load_recursive_attribute (P11KitIter *iter,
case CKR_OK:
case CKR_ATTRIBUTE_TYPE_INVALID:
case CKR_ATTRIBUTE_SENSITIVE:
rv = CKR_OK;
break;
default:
return_val_if_fail (rv != CKR_BUFFER_TOO_SMALL, rv);
Expand All @@ -1046,7 +1045,8 @@ load_recursive_attribute (P11KitIter *iter,
for (i = 0; i < count; ++i) {
attr += i;

return_val_if_fail (!IS_ATTRIBUTE_ARRAY (attr), CKR_DATA_INVALID);
/* Currently we don't support nested recursive attributes */
return_val_if_fail (!IS_ATTRIBUTE_ARRAY (attr), CKR_FUNCTION_NOT_SUPPORTED);
return_val_if_fail (attr->type != CKA_INVALID, CKR_GENERAL_ERROR);
return_val_if_fail (attr->ulValueLen != 0, CKR_GENERAL_ERROR);
return_val_if_fail (attr->ulValueLen != (CK_ULONG)-1, CKR_GENERAL_ERROR);
Expand All @@ -1055,7 +1055,7 @@ load_recursive_attribute (P11KitIter *iter,
return_val_if_fail (attr->pValue != NULL, CKR_HOST_MEMORY);
}

return rv;
return CKR_OK;
}

/**
Expand Down Expand Up @@ -1138,8 +1138,11 @@ p11_kit_iter_load_attributes (P11KitIter *iter,
return_val_if_fail (templ[i].pValue != NULL, CKR_HOST_MEMORY);

if (IS_ATTRIBUTE_ARRAY (templ + i)) {
rv = load_recursive_attribute (iter, templ + i);
return_val_if_fail (rv == CKR_OK, rv);
rv = prepare_recursive_attribute (iter, templ + i);
if (rv != CKR_OK) {
free (original);
return rv;
}
}
}
}
Expand Down

0 comments on commit 719f31b

Please sign in to comment.