Fix incorrect application state after a failed attempt to load a PKCS#11 library #112
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.
Calling the method
self.pkcs11.load(lib)
twice leads to an incorrect state of the application, if the first attempt to load a library failed. The problem is that code in__init__.py
fills the map_loaded_libs
with the library name before the library is actually loaded, and then the next call toself.pkcs11.load(lib)
finds the cached library (which wasn't properly loaded) and finishes successfully.The bug can be reproduced by simply setting an invalid PKCS#11 library name and executing the unit tests:
which in my case ended up with a segfault.
This PR proposes a fix for the problem.