rust-pkcs11 icon indicating copy to clipboard operation
rust-pkcs11 copied to clipboard

Fix use-after-free bug in Ctx::initialize

Open jhagborgftx opened this issue 3 years ago • 0 comments

Previously, init_args was being destructured by value, causing it to be dropped before C_Initialize was called. This caused undefined behavior. I believe this fixes #49.

The fact that a bug in safe code caused this is a bit worrying. In my opinion, all the function pointers in CK_FUNCTION_LIST should be marked as unsafe, and have safe wrappers that take references rather than raw pointers.

jhagborgftx avatar Feb 07 '22 23:02 jhagborgftx