aboutsummaryrefslogtreecommitdiff
path: root/src/ssl/error.rs
diff options
context:
space:
mode:
authorValerii Hiora <[email protected]>2015-01-07 15:32:51 +0200
committerValerii Hiora <[email protected]>2015-01-07 15:32:51 +0200
commit2a646916d75571e9232e3a6a5a6cd439fe639257 (patch)
tree86faf0d035e9f001d7eca8a4ce43cd1b73aa1cbf /src/ssl/error.rs
parentRelease v0.2.13 (diff)
downloadrust-openssl-2a646916d75571e9232e3a6a5a6cd439fe639257.tar.xz
rust-openssl-2a646916d75571e9232e3a6a5a6cd439fe639257.zip
Handle recent breaking changes
- macro reform - split of Show and String in formatter - CString reform - feature changes
Diffstat (limited to 'src/ssl/error.rs')
-rw-r--r--src/ssl/error.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/ssl/error.rs b/src/ssl/error.rs
index 888a9cdc..c52879a0 100644
--- a/src/ssl/error.rs
+++ b/src/ssl/error.rs
@@ -3,8 +3,8 @@ pub use self::OpensslError::*;
use libc::c_ulong;
use std::error;
+use std::ffi::c_str_to_bytes;
use std::io::IoError;
-use std::c_str::CString;
use ffi;
@@ -51,15 +51,24 @@ pub enum OpensslError {
}
fn get_lib(err: c_ulong) -> String {
- unsafe { CString::new(ffi::ERR_lib_error_string(err), false) }.to_string()
+ unsafe {
+ let bytes = c_str_to_bytes(&ffi::ERR_lib_error_string(err)).to_vec();
+ String::from_utf8(bytes).unwrap()
+ }
}
fn get_func(err: c_ulong) -> String {
- unsafe { CString::new(ffi::ERR_func_error_string(err), false).to_string() }
+ unsafe {
+ let bytes = c_str_to_bytes(&ffi::ERR_func_error_string(err)).to_vec();
+ String::from_utf8(bytes).unwrap()
+ }
}
fn get_reason(err: c_ulong) -> String {
- unsafe { CString::new(ffi::ERR_reason_error_string(err), false).to_string() }
+ unsafe {
+ let bytes = c_str_to_bytes(&ffi::ERR_reason_error_string(err)).to_vec();
+ String::from_utf8(bytes).unwrap()
+ }
}
impl SslError {
@@ -100,7 +109,7 @@ fn test_uknown_error_should_have_correct_messages() {
let UnknownError { ref library, ref function, ref reason } = errs[0];
- assert_eq!(library.as_slice(),"SSL routines");
+ assert_eq!(library.as_slice(), "SSL routines");
assert_eq!(function.as_slice(), "SSL23_GET_SERVER_HELLO");
assert_eq!(reason.as_slice(), "sslv3 alert handshake failure");
}