Skip to content

_pkcs11.pyx: Fix Python int too large to convert to C ssize_t #201

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

Closed
wants to merge 1 commit into from

Conversation

jrripple
Copy link

@jrripple jrripple commented Jun 5, 2025

When a key is retrieved it can return CK_UNAVAILABLE_INFORMATION for some of its properties. The CK_UNAVAILABLE_INFORMATION value is set to ~0UL or the largest int possible on a system. The python-pkcs11 library would then try to create a buffer of that size and crash.

This commit adds error checking to make sure when
CK_UNAVAILABLE_INFORMATION is returned that the property value is set to blank and returned immediately.

When a key is retrieved it can retrun CK_UNAVAILABLE_INFORMATION for
some of its properties. The CK_UNAVAILABLE_INFORMATION value is set to
~0UL or the largest int possible on a system. The python-pkcs11 library
would then try to create a buffer of that size and crash.

This commit adds error checking to make sure when
CK_UNAVAILABLE_INFORMATION is returned that the property value is set to
blank and returned immediately.
@jrripple
Copy link
Author

jrripple commented Jun 5, 2025

Closing this since @minego did it better in #200

@jrripple jrripple closed this Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant