Merge branch 'release-v0.7.8' into release

This commit is contained in:
Steven Fackler 2016-03-18 08:54:15 -07:00
commit 9043d3235e
9 changed files with 21 additions and 63 deletions

View File

@ -2,7 +2,7 @@
[![Build Status](https://travis-ci.org/sfackler/rust-openssl.svg?branch=master)](https://travis-ci.org/sfackler/rust-openssl) [![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 ## Building

View File

@ -1,11 +1,11 @@
[package] [package]
name = "openssl-sys-extras" name = "openssl-sys-extras"
version = "0.7.7" version = "0.7.8"
authors = ["Steven Fackler <sfackler@gmail.com>"] authors = ["Steven Fackler <sfackler@gmail.com>"]
license = "MIT" license = "MIT"
description = "Extra FFI bindings to OpenSSL that require a C shim" description = "Extra FFI bindings to OpenSSL that require a C shim"
repository = "https://github.com/sfackler/rust-openssl" 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" build = "build.rs"
[features] [features]
@ -13,7 +13,7 @@ ecdh_auto = []
[dependencies] [dependencies]
libc = "0.2" libc = "0.2"
openssl-sys = { version = "0.7.7", path = "../openssl-sys" } openssl-sys = { version = "0.7.8", path = "../openssl-sys" }
[build-dependencies] [build-dependencies]
gcc = "0.3" gcc = "0.3"

View File

@ -1,5 +1,5 @@
#![allow(non_upper_case_globals, non_snake_case)] #![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 openssl_sys;
extern crate libc; extern crate libc;

View File

@ -1,12 +1,12 @@
[package] [package]
name = "openssl-sys" name = "openssl-sys"
version = "0.7.7" version = "0.7.8"
authors = ["Alex Crichton <alex@alexcrichton.com>", authors = ["Alex Crichton <alex@alexcrichton.com>",
"Steven Fackler <sfackler@gmail.com>"] "Steven Fackler <sfackler@gmail.com>"]
license = "MIT" license = "MIT"
description = "FFI bindings to OpenSSL" description = "FFI bindings to OpenSSL"
repository = "https://github.com/sfackler/rust-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" links = "openssl"
build = "build.rs" build = "build.rs"

View File

@ -1,6 +1,6 @@
#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] #![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
#![allow(dead_code)] #![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; extern crate libc;

View File

@ -1,11 +1,11 @@
[package] [package]
name = "openssl" name = "openssl"
version = "0.7.7" version = "0.7.8"
authors = ["Steven Fackler <sfackler@gmail.com>"] authors = ["Steven Fackler <sfackler@gmail.com>"]
license = "Apache-2.0" license = "Apache-2.0"
description = "OpenSSL bindings" description = "OpenSSL bindings"
repository = "https://github.com/sfackler/rust-openssl" 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" readme = "../README.md"
keywords = ["crypto", "tls", "ssl", "dtls"] keywords = ["crypto", "tls", "ssl", "dtls"]
build = "build.rs" build = "build.rs"
@ -32,8 +32,8 @@ nightly = []
bitflags = "0.4" bitflags = "0.4"
lazy_static = "0.1" lazy_static = "0.1"
libc = "0.2" libc = "0.2"
openssl-sys = { version = "0.7.7", path = "../openssl-sys" } openssl-sys = { version = "0.7.8", path = "../openssl-sys" }
openssl-sys-extras = { version = "0.7.7", path = "../openssl-sys-extras" } openssl-sys-extras = { version = "0.7.8", path = "../openssl-sys-extras" }
[build-dependencies] [build-dependencies]
gcc = "0.3" gcc = "0.3"

View File

@ -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))] #![cfg_attr(feature = "nightly", feature(const_fn, recover, panic_propagate))]
#[macro_use] #[macro_use]

View File

@ -11,9 +11,6 @@ use std::sync::Arc;
use ssl::error::SslError; use ssl::error::SslError;
// "rust"
const NAME: [c_char; 5] = [114, 117, 115, 116, 0];
pub struct StreamState<S> { pub struct StreamState<S> {
pub stream: S, pub stream: S,
pub error: Option<io::Error>, pub error: Option<io::Error>,
@ -23,7 +20,7 @@ pub struct StreamState<S> {
pub fn new<S: Read + Write>(stream: S) -> Result<(*mut BIO, Arc<BIO_METHOD>), SslError> { pub fn new<S: Read + Write>(stream: S) -> Result<(*mut BIO, Arc<BIO_METHOD>), SslError> {
let method = Arc::new(BIO_METHOD { let method = Arc::new(BIO_METHOD {
type_: BIO_TYPE_NONE, type_: BIO_TYPE_NONE,
name: &NAME[0], name: b"rust\0".as_ptr() as *const _,
bwrite: Some(bwrite::<S>), bwrite: Some(bwrite::<S>),
bread: Some(bread::<S>), bread: Some(bread::<S>),
bputs: Some(bputs::<S>), bputs: Some(bputs::<S>),
@ -74,8 +71,8 @@ unsafe fn state<'a, S: 'a>(bio: *mut BIO) -> &'a mut StreamState<S> {
} }
#[cfg(feature = "nightly")] #[cfg(feature = "nightly")]
fn recover<F, T>(f: F) -> Result<T, Box<Any + Send>> where F: FnOnce() -> T + ::std::panic::RecoverSafe { fn recover<F, T>(f: F) -> Result<T, Box<Any + Send>> where F: FnOnce() -> T {
::std::panic::recover(f) ::std::panic::recover(::std::panic::AssertRecoverSafe::new(f))
} }
#[cfg(not(feature = "nightly"))] #[cfg(not(feature = "nightly"))]
@ -83,45 +80,13 @@ fn recover<F, T>(f: F) -> Result<T, Box<Any + Send>> where F: FnOnce() -> T {
Ok(f()) Ok(f())
} }
#[cfg(feature = "nightly")]
use std::panic::AssertRecoverSafe;
#[cfg(not(feature = "nightly"))]
struct AssertRecoverSafe<T>(T);
#[cfg(not(feature = "nightly"))]
impl<T> AssertRecoverSafe<T> {
fn new(t: T) -> Self {
AssertRecoverSafe(t)
}
}
#[cfg(not(feature = "nightly"))]
impl<T> ::std::ops::Deref for AssertRecoverSafe<T> {
type Target = T;
fn deref(&self) -> &T {
&self.0
}
}
#[cfg(not(feature = "nightly"))]
impl<T> ::std::ops::DerefMut for AssertRecoverSafe<T> {
fn deref_mut(&mut self) -> &mut T {
&mut self.0
}
}
unsafe extern "C" fn bwrite<S: Write>(bio: *mut BIO, buf: *const c_char, len: c_int) -> c_int { unsafe extern "C" fn bwrite<S: Write>(bio: *mut BIO, buf: *const c_char, len: c_int) -> c_int {
BIO_clear_retry_flags(bio); BIO_clear_retry_flags(bio);
let state = state::<S>(bio); let state = state::<S>(bio);
let buf = slice::from_raw_parts(buf as *const _, len as usize); let buf = slice::from_raw_parts(buf as *const _, len as usize);
let result = { let result = recover(|| state.stream.write(buf));
let mut youre_not_my_supervisor = AssertRecoverSafe::new(&mut *state);
recover(move || youre_not_my_supervisor.stream.write(buf))
};
match result { match result {
Ok(Ok(len)) => len as c_int, Ok(Ok(len)) => len as c_int,
@ -145,11 +110,7 @@ unsafe extern "C" fn bread<S: Read>(bio: *mut BIO, buf: *mut c_char, len: c_int)
let state = state::<S>(bio); let state = state::<S>(bio);
let buf = slice::from_raw_parts_mut(buf as *mut _, len as usize); let buf = slice::from_raw_parts_mut(buf as *mut _, len as usize);
let result = { let result = recover(|| state.stream.read(buf));
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))
};
match result { match result {
Ok(Ok(len)) => len as c_int, Ok(Ok(len)) => len as c_int,
@ -185,10 +146,7 @@ unsafe extern "C" fn ctrl<S: Write>(bio: *mut BIO,
-> c_long { -> c_long {
if cmd == BIO_CTRL_FLUSH { if cmd == BIO_CTRL_FLUSH {
let state = state::<S>(bio); let state = state::<S>(bio);
let result = { let result = recover(|| state.stream.flush());
let mut youre_not_my_supervisor = AssertRecoverSafe::new(&mut *state);
recover(move || youre_not_my_supervisor.stream.flush())
};
match result { match result {
Ok(Ok(())) => 1, Ok(Ok(())) => 1,

View File

@ -823,8 +823,8 @@ impl <'a> SslCipher<'a> {
pub fn description(&self) -> Option<String> { pub fn description(&self) -> Option<String> {
unsafe { unsafe {
// SSL_CIPHER_description requires a buffer of at least 128 bytes. // SSL_CIPHER_description requires a buffer of at least 128 bytes.
let mut buf = [0i8; 128]; let mut buf = [0; 128];
let desc_ptr = ffi::SSL_CIPHER_description(self.cipher, &mut buf[0], 128); let desc_ptr = ffi::SSL_CIPHER_description(self.cipher, buf.as_mut_ptr(), 128);
if !desc_ptr.is_null() { if !desc_ptr.is_null() {
String::from_utf8(CStr::from_ptr(desc_ptr).to_bytes().to_vec()).ok() String::from_utf8(CStr::from_ptr(desc_ptr).to_bytes().to_vec()).ok()