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

Fix incorrect application state after a failed attempt to load a PKCS#11 library #112

Merged

Conversation

fuzzykat
Copy link
Contributor

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 to self.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:

export PYKCS11LIB=/path/to/invalid/lib.so
./run_test.py

which in my case ended up with a segfault.
This PR proposes a fix for the problem.

@coveralls
Copy link

Coverage Status

coverage: 88.33% (+0.02%) from 88.308%
when pulling 1287b8a on fuzzykat:bugfix/cached_libname
into eaded3b on LudovicRousseau:master.

@LudovicRousseau LudovicRousseau merged commit 1287b8a into LudovicRousseau:master Apr 16, 2024
15 checks passed
@LudovicRousseau
Copy link
Owner

Thanks

@fuzzykat fuzzykat deleted the bugfix/cached_libname branch April 17, 2024 07:26
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.

3 participants