Fix crash when closing sessions with vendor-specific user types#231
Merged
MatthiasValvekens merged 2 commits intoJun 17, 2026
Conversation
Collaborator
|
Those failing tests seem to be related to an upstream change (#233). I pushed a change to master to disable the offending test when running against |
Contributor
Author
|
Thanks. I merged the change from |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #231 +/- ##
==========================================
+ Coverage 90.17% 91.40% +1.23%
==========================================
Files 15 15
Lines 2625 2677 +52
Branches 29 27 -2
==========================================
+ Hits 2367 2447 +80
+ Misses 255 228 -27
+ Partials 3 2 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
Nice work. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #230
In the current version of this package, when using a custom user such as the Crypto User -- represented by value
0x80000001-- on Thales Luna HSM 7, we run into problems when closing a session because:Session.close()method callsSession.user_type(). (Both methods are defined inpkcs11/_pkcs11.pyx.)Session.user_type()then callsUserType().UserType(), defined inpkcs11/constants.py, crashes because the custom user value0x80000001does not matchNOBODY(999),SO(0), orUSER(1).This PR fixes the problem by avoiding the indirect call to
UserType()inSession.close(). It also updatesSession.user_type()to not crash if the user type is a custom user.