aboutsummaryrefslogtreecommitdiff
path: root/openssl/src/util.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2016-11-13 16:18:52 +0000
committerSteven Fackler <[email protected]>2016-11-13 16:18:52 +0000
commited9f600e2889906bb928150d7e892370062f6ca1 (patch)
tree4fc24159db5184d1cfd36dc6c36a65c90479c324 /openssl/src/util.rs
parentSupport serialization of encrypted private keys (diff)
downloadrust-openssl-ed9f600e2889906bb928150d7e892370062f6ca1.tar.xz
rust-openssl-ed9f600e2889906bb928150d7e892370062f6ca1.zip
Make password callback return a Result
Diffstat (limited to 'openssl/src/util.rs')
-rw-r--r--openssl/src/util.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/openssl/src/util.rs b/openssl/src/util.rs
index dea94668..f4883976 100644
--- a/openssl/src/util.rs
+++ b/openssl/src/util.rs
@@ -4,6 +4,8 @@ use std::cell::UnsafeCell;
use std::panic::{self, AssertUnwindSafe};
use std::slice;
+use error::ErrorStack;
+
/// Wraps a user-supplied callback and a slot for panics thrown inside the callback (while FFI
/// frames are on the stack).
///
@@ -64,7 +66,7 @@ pub unsafe extern fn invoke_passwd_cb<F>(buf: *mut c_char,
_rwflag: c_int,
cb_state: *mut c_void)
-> c_int
- where F: FnOnce(&mut [u8]) -> usize
+ where F: FnOnce(&mut [u8]) -> Result<usize, ErrorStack>
{
let callback = &mut *(cb_state as *mut CallbackState<F>);
@@ -74,7 +76,11 @@ pub unsafe extern fn invoke_passwd_cb<F>(buf: *mut c_char,
}));
match result {
- Ok(len) => len as c_int,
+ Ok(Ok(len)) => len as c_int,
+ Ok(Err(_)) => {
+ // FIXME restore error stack
+ 0
+ }
Err(err) => {
callback.panic = Some(err);
0