Devolutions / sspi-rs

A Rust implementation of the Security Support Provider Interface (SSPI) API
Apache License 2.0
52 stars 14 forks source link

fix: fix memory leak during encryption #254

Closed TheBestTvarynka closed 3 months ago

TheBestTvarynka commented 3 months ago

Hi, In this pull request, I've fixed the memory leak during data encryption.

My approach is the same, as I did for the decryption (#219): now we use buffers with references to the input data instead of data copying.

Don't be afraid of so many files changed. I just renamed two commonly used structures:

Moreover, I added a test for testing encryption and decryption in the FFI layer. I highly recommend running FFI tests with Miri.

[!NOTE] Currently, we cannot run Miri because one dependency in the dependency tree has failed to compile with nightly Rust.

I already fixed it and found some UB and memory leaks. I'll provide a separate PR with an updated Cargo.lock and another PR for UB + memory leak fixes.

closes #217

CBenoit commented 3 months ago

Moreover, I added a test for testing encryption and decryption in the FFI layer. I highly recommend running FFI tests with Miri.

Definitely. I’ll update the CI to add this once the next PR is landed.