diff --git a/README.md b/README.md index e51cbc4a4a35f061dfa974c05949757a11b94b10..6f3bf7cbd8fd8f0cbdabbc85bde1c3579dca3d4c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/sfackler/rust-openssl.svg?branch=master)](https://travis-ci.org/sfackler/rust-openssl) -[Documentation](https://sfackler.github.io/rust-openssl/doc/v0.7.7/openssl). +[Documentation](https://sfackler.github.io/rust-openssl/doc/v0.7.8/openssl). ## Building diff --git a/openssl-sys-extras/Cargo.toml b/openssl-sys-extras/Cargo.toml index 79bfa097a519ee507ea0fa6ec98cecce49bec05c..29e2c862b64afedbf45b72dc484b881b0b1e304d 100644 --- a/openssl-sys-extras/Cargo.toml +++ b/openssl-sys-extras/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "openssl-sys-extras" -version = "0.7.7" +version = "0.7.8" authors = ["Steven Fackler "] license = "MIT" description = "Extra FFI bindings to OpenSSL that require a C shim" repository = "https://github.com/sfackler/rust-openssl" -documentation = "https://sfackler.github.io/rust-openssl/doc/v0.7.7/openssl_sys_extras" +documentation = "https://sfackler.github.io/rust-openssl/doc/v0.7.8/openssl_sys_extras" build = "build.rs" [features] @@ -13,7 +13,7 @@ ecdh_auto = [] [dependencies] libc = "0.2" -openssl-sys = { version = "0.7.7", path = "../openssl-sys" } +openssl-sys = { version = "0.7.8", path = "../openssl-sys" } [build-dependencies] gcc = "0.3" diff --git a/openssl-sys-extras/src/lib.rs b/openssl-sys-extras/src/lib.rs index 58760fb6ccfc4f0108329156e7ce7c6c9febc995..890c323b75b9302aa37af019705ba491a339150e 100644 --- a/openssl-sys-extras/src/lib.rs +++ b/openssl-sys-extras/src/lib.rs @@ -1,5 +1,5 @@ #![allow(non_upper_case_globals, non_snake_case)] -#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.7.7")] +#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.7.8")] extern crate openssl_sys; extern crate libc; diff --git a/openssl-sys/Cargo.toml b/openssl-sys/Cargo.toml index 2a9ae1fb4966727806f7b15184fc7bc79d28fcdf..2498c2342a27b21013d21664d725d080bcd4ad9b 100644 --- a/openssl-sys/Cargo.toml +++ b/openssl-sys/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "openssl-sys" -version = "0.7.7" +version = "0.7.8" authors = ["Alex Crichton ", "Steven Fackler "] license = "MIT" description = "FFI bindings to OpenSSL" repository = "https://github.com/sfackler/rust-openssl" -documentation = "https://sfackler.github.io/rust-openssl/doc/v0.7.7/openssl_sys" +documentation = "https://sfackler.github.io/rust-openssl/doc/v0.7.8/openssl_sys" links = "openssl" build = "build.rs" diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs index 8017a1ed6511be77c118dba88105a345654d366e..6d6d6103ca319fbbfa872a20bb57cf7815fb1041 100644 --- a/openssl-sys/src/lib.rs +++ b/openssl-sys/src/lib.rs @@ -1,6 +1,6 @@ #![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] #![allow(dead_code)] -#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.7.7")] +#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.7.8")] extern crate libc; diff --git a/openssl/Cargo.toml b/openssl/Cargo.toml index 39adb0e3c9c30b69fd7dbf07fd3bdeafc36860ff..5bfd3edb04cc923312f09f34296f27e0e0f9499d 100644 --- a/openssl/Cargo.toml +++ b/openssl/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "openssl" -version = "0.7.7" +version = "0.7.8" authors = ["Steven Fackler "] license = "Apache-2.0" description = "OpenSSL bindings" repository = "https://github.com/sfackler/rust-openssl" -documentation = "https://sfackler.github.io/rust-openssl/doc/v0.7.7/openssl" +documentation = "https://sfackler.github.io/rust-openssl/doc/v0.7.8/openssl" readme = "../README.md" keywords = ["crypto", "tls", "ssl", "dtls"] build = "build.rs" @@ -32,8 +32,8 @@ nightly = [] bitflags = "0.4" lazy_static = "0.1" libc = "0.2" -openssl-sys = { version = "0.7.7", path = "../openssl-sys" } -openssl-sys-extras = { version = "0.7.7", path = "../openssl-sys-extras" } +openssl-sys = { version = "0.7.8", path = "../openssl-sys" } +openssl-sys-extras = { version = "0.7.8", path = "../openssl-sys-extras" } [build-dependencies] gcc = "0.3" diff --git a/openssl/src/lib.rs b/openssl/src/lib.rs index e89e6590012a316f15645afd3d493a7b9fdaa476..9db1df92172a0c4391c32dad69b824210f21033a 100644 --- a/openssl/src/lib.rs +++ b/openssl/src/lib.rs @@ -1,4 +1,4 @@ -#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.7.7")] +#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.7.8")] #![cfg_attr(feature = "nightly", feature(const_fn, recover, panic_propagate))] #[macro_use] diff --git a/openssl/src/ssl/bio.rs b/openssl/src/ssl/bio.rs index aa445562fd9797311733f7306cdee77dd440e683..8d2959281977de053713c6bb83c3f3493afb5b27 100644 --- a/openssl/src/ssl/bio.rs +++ b/openssl/src/ssl/bio.rs @@ -11,9 +11,6 @@ use std::sync::Arc; use ssl::error::SslError; -// "rust" -const NAME: [c_char; 5] = [114, 117, 115, 116, 0]; - pub struct StreamState { pub stream: S, pub error: Option, @@ -23,7 +20,7 @@ pub struct StreamState { pub fn new(stream: S) -> Result<(*mut BIO, Arc), SslError> { let method = Arc::new(BIO_METHOD { type_: BIO_TYPE_NONE, - name: &NAME[0], + name: b"rust\0".as_ptr() as *const _, bwrite: Some(bwrite::), bread: Some(bread::), bputs: Some(bputs::), @@ -74,8 +71,8 @@ unsafe fn state<'a, S: 'a>(bio: *mut BIO) -> &'a mut StreamState { } #[cfg(feature = "nightly")] -fn recover(f: F) -> Result> where F: FnOnce() -> T + ::std::panic::RecoverSafe { - ::std::panic::recover(f) +fn recover(f: F) -> Result> where F: FnOnce() -> T { + ::std::panic::recover(::std::panic::AssertRecoverSafe::new(f)) } #[cfg(not(feature = "nightly"))] @@ -83,45 +80,13 @@ fn recover(f: F) -> Result> where F: FnOnce() -> T { Ok(f()) } -#[cfg(feature = "nightly")] -use std::panic::AssertRecoverSafe; - -#[cfg(not(feature = "nightly"))] -struct AssertRecoverSafe(T); - -#[cfg(not(feature = "nightly"))] -impl AssertRecoverSafe { - fn new(t: T) -> Self { - AssertRecoverSafe(t) - } -} - -#[cfg(not(feature = "nightly"))] -impl ::std::ops::Deref for AssertRecoverSafe { - type Target = T; - - fn deref(&self) -> &T { - &self.0 - } -} - -#[cfg(not(feature = "nightly"))] -impl ::std::ops::DerefMut for AssertRecoverSafe { - fn deref_mut(&mut self) -> &mut T { - &mut self.0 - } -} - unsafe extern "C" fn bwrite(bio: *mut BIO, buf: *const c_char, len: c_int) -> c_int { BIO_clear_retry_flags(bio); let state = state::(bio); let buf = slice::from_raw_parts(buf as *const _, len as usize); - let result = { - let mut youre_not_my_supervisor = AssertRecoverSafe::new(&mut *state); - recover(move || youre_not_my_supervisor.stream.write(buf)) - }; + let result = recover(|| state.stream.write(buf)); match result { Ok(Ok(len)) => len as c_int, @@ -145,11 +110,7 @@ unsafe extern "C" fn bread(bio: *mut BIO, buf: *mut c_char, len: c_int) let state = state::(bio); let buf = slice::from_raw_parts_mut(buf as *mut _, len as usize); - let result = { - let mut youre_not_my_supervisor = AssertRecoverSafe::new(&mut *state); - let mut fuuuu = AssertRecoverSafe::new(buf); - recover(move || youre_not_my_supervisor.stream.read(&mut *fuuuu)) - }; + let result = recover(|| state.stream.read(buf)); match result { Ok(Ok(len)) => len as c_int, @@ -185,10 +146,7 @@ unsafe extern "C" fn ctrl(bio: *mut BIO, -> c_long { if cmd == BIO_CTRL_FLUSH { let state = state::(bio); - let result = { - let mut youre_not_my_supervisor = AssertRecoverSafe::new(&mut *state); - recover(move || youre_not_my_supervisor.stream.flush()) - }; + let result = recover(|| state.stream.flush()); match result { Ok(Ok(())) => 1, diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs index 574a324b0d3488937c1d8cfdfd22733713ea1343..38527dc6d744ee40b5480542a667ccc9becf182a 100644 --- a/openssl/src/ssl/mod.rs +++ b/openssl/src/ssl/mod.rs @@ -823,8 +823,8 @@ impl <'a> SslCipher<'a> { pub fn description(&self) -> Option { unsafe { // SSL_CIPHER_description requires a buffer of at least 128 bytes. - let mut buf = [0i8; 128]; - let desc_ptr = ffi::SSL_CIPHER_description(self.cipher, &mut buf[0], 128); + let mut buf = [0; 128]; + let desc_ptr = ffi::SSL_CIPHER_description(self.cipher, buf.as_mut_ptr(), 128); if !desc_ptr.is_null() { String::from_utf8(CStr::from_ptr(desc_ptr).to_bytes().to_vec()).ok()