mathstuf / rust-keyutils

Rust interface to the Linux keyring
BSD 3-Clause "New" or "Revised" License
17 stars 9 forks source link

api: update the use of as_ptr to ensure the reference to self is always valid #4

Closed derekstraka closed 8 years ago

derekstraka commented 8 years ago

The existing use of as_ptr did not guarantee that self was always valid. Depending on the optimizations of LLVM, the memory may have been freed immediately after creation rather than after the completion of the function call. This left the pointee memory in a non-deterministic state causing garbage values to be send to the system calls. Updated the usage of as_ptr to ensure the CString objects remained around through the lifetime of the pointer usage as described in std::ffi::CString as_ptr documentation.

mathstuf commented 8 years ago

Thanks! Was this found by searching crates.io or are you using the library?

derekstraka commented 8 years ago

I'm using the library in a project. When you get a chance, would you be able to bump the minor version number to 0.2.1, so I can specify that version in my toml? Thanks.

mathstuf commented 8 years ago

Yeah. My cargo key is at home.

mathstuf commented 8 years ago

Oh, you don't need a publish.

mathstuf commented 8 years ago

Tag added too.

derekstraka commented 8 years ago

Were you going to publish the update on crates.io too?

mathstuf commented 8 years ago

Oops, yep. Added a task to my list.