diff options
| author | Steven Fackler <[email protected]> | 2018-02-25 22:11:08 -0800 |
|---|---|---|
| committer | Steven Fackler <[email protected]> | 2018-02-25 22:11:08 -0800 |
| commit | d5dd6575c16a3eebc53b8d91b9642d3741b108cc (patch) | |
| tree | 599208ec4edc3473813598eef71f3530b9372cbb /openssl/src | |
| parent | Merge pull request #835 from Ralith/stateless (diff) | |
| download | rust-openssl-d5dd6575c16a3eebc53b8d91b9642d3741b108cc.tar.xz rust-openssl-d5dd6575c16a3eebc53b8d91b9642d3741b108cc.zip | |
Restore error stack in cookie callback
Diffstat (limited to 'openssl/src')
| -rw-r--r-- | openssl/src/ssl/callbacks.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/openssl/src/ssl/callbacks.rs b/openssl/src/ssl/callbacks.rs index 424bdc1a..60d40fc7 100644 --- a/openssl/src/ssl/callbacks.rs +++ b/openssl/src/ssl/callbacks.rs @@ -365,10 +365,10 @@ where pub extern "C" fn raw_cookie_generate<F>( ssl: *mut ffi::SSL, cookie: *mut c_uchar, - cookie_len: *mut c_uint + cookie_len: *mut c_uint, ) -> c_int where - F: Fn(&mut SslRef, &mut [u8]) -> Result<usize, ErrorStack> + 'static + Sync + Send + F: Fn(&mut SslRef, &mut [u8]) -> Result<usize, ErrorStack> + 'static + Sync + Send, { unsafe { let ssl_ctx = ffi::SSL_get_SSL_CTX(ssl as *const _); @@ -377,13 +377,17 @@ where let callback = &*(callback as *mut F); // We subtract 1 from DTLS1_COOKIE_LENGTH as the ostensible value, 256, is erroneous but retained for // compatibility. See comments in dtls1.h. - let slice = slice::from_raw_parts_mut(cookie as *mut u8, ffi::DTLS1_COOKIE_LENGTH as usize - 1); + let slice = + slice::from_raw_parts_mut(cookie as *mut u8, ffi::DTLS1_COOKIE_LENGTH as usize - 1); match callback(ssl, slice) { Ok(len) => { *cookie_len = len as c_uint; 1 } - Err(_) => 0, + Err(e) => { + e.put(); + 0 + } } } } @@ -397,17 +401,18 @@ type CookiePtr = *mut c_uchar; pub extern "C" fn raw_cookie_verify<F>( ssl: *mut ffi::SSL, cookie: CookiePtr, - cookie_len: c_uint + cookie_len: c_uint, ) -> c_int where - F: Fn(&mut SslRef, &[u8]) -> bool + 'static + Sync + Send + F: Fn(&mut SslRef, &[u8]) -> bool + 'static + Sync + Send, { unsafe { let ssl_ctx = ffi::SSL_get_SSL_CTX(ssl as *const _); let callback = ffi::SSL_CTX_get_ex_data(ssl_ctx, get_callback_idx::<F>()); let ssl = SslRef::from_ptr_mut(ssl); let callback = &*(callback as *mut F); - let slice = slice::from_raw_parts(cookie as *const c_uchar as *const u8, cookie_len as usize); + let slice = + slice::from_raw_parts(cookie as *const c_uchar as *const u8, cookie_len as usize); callback(ssl, slice) as c_int } } |