Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C_GetAttributeValue does not set the attribute length in all cases #170

Closed
sbertin-telular opened this issue Mar 13, 2023 · 3 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@sbertin-telular
Copy link

sbertin-telular commented Mar 13, 2023

The attribute length is only set when the pointer is NULL. It should also be set in cases where the buffer is too large or too small.

From PKCS11-base-v2.40:
For each (type, pValue, ulValueLen) triple in the template, C_GetAttributeValue performs the following algorithm:

  1. If the specified attribute (i.e., the attribute specified by the type field) for the object cannot be revealed because the object is sensitive or unextractable, then the ulValueLen field in that triple is modified to hold the value CK_UNAVAILABLE_INFORMATION.
  2. Otherwise, if the specified value for the object is invalid (the object does not possess such an attribute), then the ulValueLen field in that triple is modified to hold the value CK_UNAVAILABLE_INFORMATION.
  3. Otherwise, if the pValue field has the value NULL_PTR, then the ulValueLen field is modified to hold the exact length of the specified attribute for the object.
  4. Otherwise, if the length specified in ulValueLen is large enough to hold the value of the specified attribute for the object, then that attribute is copied into the buffer located at pValue, and the ulValueLen field is modified to hold the exact length of the attribute.
  5. Otherwise, the ulValueLen field is modified to hold the value CK_UNAVAILABLE_INFORMATION.
@paulbartell paulbartell added the bug Something isn't working label Mar 13, 2023
@paulbartell
Copy link
Contributor

@sbertin-telular Thanks for the report. I will take a look.

@chinglee-iot
Copy link
Member

chinglee-iot commented May 10, 2024

@sbertin-telular
I have created a pull request #193 to address this issue, and I would like to invite you to review the proposed changes to see if they adequately resolve the issue.

@chinglee-iot
Copy link
Member

The PR to address this problem is merged. We will close this issue. Feel free to reopen it if any further question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants