Merge pull request #306 from overminder/get1-leak-fix

Fix a leak when using `EVP_PKEY_get1_RSA`.
This commit is contained in:
Steven Fackler 2015-11-17 20:40:46 -08:00
commit ccd3a1cf07
2 changed files with 2 additions and 0 deletions

View File

@ -482,6 +482,7 @@ extern "C" {
pub fn RAND_bytes(buf: *mut u8, num: c_int) -> c_int; pub fn RAND_bytes(buf: *mut u8, num: c_int) -> c_int;
pub fn RSA_free(rsa: *mut RSA);
pub fn RSA_generate_key(modsz: c_int, e: c_ulong, cb: *const c_void, cbarg: *const c_void) -> *mut RSA; pub fn RSA_generate_key(modsz: c_int, e: c_ulong, cb: *const c_void, cbarg: *const c_void) -> *mut RSA;
pub fn RSA_generate_key_ex(rsa: *mut RSA, bits: c_int, e: *mut BIGNUM, cb: *const c_void) -> c_int; pub fn RSA_generate_key_ex(rsa: *mut RSA, bits: c_int, e: *mut BIGNUM, cb: *const c_void) -> c_int;
pub fn RSA_private_decrypt(flen: c_int, from: *const u8, to: *mut u8, k: *mut RSA, pub fn RSA_private_decrypt(flen: c_int, from: *const u8, to: *mut u8, k: *mut RSA,

View File

@ -120,6 +120,7 @@ impl PKey {
let mut s = repeat(0u8).take(len as usize).collect::<Vec<_>>(); let mut s = repeat(0u8).take(len as usize).collect::<Vec<_>>();
let r = f(rsa, &s.as_mut_ptr()); let r = f(rsa, &s.as_mut_ptr());
ffi::RSA_free(rsa);
s.truncate(r as usize); s.truncate(r as usize);
s s