aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--openssl-sys/Cargo.toml4
-rw-r--r--openssl-sys/src/lib.rs2
-rw-r--r--openssl/Cargo.toml6
-rw-r--r--openssl/src/lib.rs2
-rw-r--r--openssl/src/ssl/mod.rs14
-rw-r--r--openssl/src/ssl/tests/mod.rs10
7 files changed, 32 insertions, 8 deletions
diff --git a/README.md b/README.md
index 0f1eb435..9a6d41c8 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.9.2/openssl).
+[Documentation](https://docs.rs/openssl/0.9.3/openssl).
## Warning
diff --git a/openssl-sys/Cargo.toml b/openssl-sys/Cargo.toml
index e533054f..7e827ed6 100644
--- a/openssl-sys/Cargo.toml
+++ b/openssl-sys/Cargo.toml
@@ -1,12 +1,12 @@
[package]
name = "openssl-sys"
-version = "0.9.2"
+version = "0.9.3"
authors = ["Alex Crichton <[email protected]>",
"Steven Fackler <[email protected]>"]
license = "MIT"
description = "FFI bindings to OpenSSL"
repository = "https://github.com/sfackler/rust-openssl"
-documentation = "https://sfackler.github.io/rust-openssl/doc/v0.9.2/openssl_sys"
+documentation = "https://docs.rs/openssl-sys/0.9.3/openssl_sys"
links = "openssl"
build = "build.rs"
diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs
index 8c4d1acf..c67c2f2d 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, overflowing_literals)]
-#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.9.2")]
+#![doc(html_root_url="https://docs.rs/openssl-sys/0.9.3")]
extern crate libc;
diff --git a/openssl/Cargo.toml b/openssl/Cargo.toml
index da7802f6..9de27903 100644
--- a/openssl/Cargo.toml
+++ b/openssl/Cargo.toml
@@ -1,11 +1,11 @@
[package]
name = "openssl"
-version = "0.9.2"
+version = "0.9.3"
authors = ["Steven Fackler <[email protected]>"]
license = "Apache-2.0"
description = "OpenSSL bindings"
repository = "https://github.com/sfackler/rust-openssl"
-documentation = "https://sfackler.github.io/rust-openssl/doc/v0.9.2/openssl"
+documentation = "https://docs.rs/openssl/0.9.3/openssl"
readme = "../README.md"
keywords = ["crypto", "tls", "ssl", "dtls"]
build = "build.rs"
@@ -20,7 +20,7 @@ v110 = []
bitflags = "0.7"
lazy_static = "0.2"
libc = "0.2"
-openssl-sys = { version = "0.9.2", path = "../openssl-sys" }
+openssl-sys = { version = "0.9.3", path = "../openssl-sys" }
[dev-dependencies]
tempdir = "0.3"
diff --git a/openssl/src/lib.rs b/openssl/src/lib.rs
index 75d88483..5d881d64 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.9.2")]
+#![doc(html_root_url="https://docs.rs/openssl/0.9.3")]
#[macro_use]
extern crate bitflags;
diff --git a/openssl/src/ssl/mod.rs b/openssl/src/ssl/mod.rs
index 9803949d..3eead8f2 100644
--- a/openssl/src/ssl/mod.rs
+++ b/openssl/src/ssl/mod.rs
@@ -1509,6 +1509,15 @@ impl<S: Read + Write> SslStream<S> {
/// This is particularly useful with a nonblocking socket, where the error
/// value will identify if OpenSSL is waiting on read or write readiness.
pub fn ssl_read(&mut self, buf: &mut [u8]) -> Result<usize, Error> {
+ // The intepretation of the return code here is a little odd with a
+ // zero-length write. OpenSSL will likely correctly report back to us
+ // that it read zero bytes, but zero is also the sentinel for "error".
+ // To avoid that confusion short-circuit that logic and return quickly
+ // if `buf` has a length of zero.
+ if buf.len() == 0 {
+ return Ok(0)
+ }
+
let ret = self.ssl.read(buf);
if ret > 0 {
Ok(ret as usize)
@@ -1526,6 +1535,11 @@ impl<S: Read + Write> SslStream<S> {
/// This is particularly useful with a nonblocking socket, where the error
/// value will identify if OpenSSL is waiting on read or write readiness.
pub fn ssl_write(&mut self, buf: &[u8]) -> Result<usize, Error> {
+ // See above for why we short-circuit on zero-length buffers
+ if buf.len() == 0 {
+ return Ok(0)
+ }
+
let ret = self.ssl.write(buf);
if ret > 0 {
Ok(ret as usize)
diff --git a/openssl/src/ssl/tests/mod.rs b/openssl/src/ssl/tests/mod.rs
index 437bec8a..e685d658 100644
--- a/openssl/src/ssl/tests/mod.rs
+++ b/openssl/src/ssl/tests/mod.rs
@@ -421,6 +421,16 @@ fn test_write() {
stream.flush().unwrap();
}
+#[test]
+fn zero_length_buffers() {
+ let (_s, stream) = Server::new();
+ let ctx = SslContext::builder(SslMethod::tls()).unwrap();
+ let mut stream = Ssl::new(&ctx.build()).unwrap().connect(stream).unwrap();
+
+ assert_eq!(stream.write(b"").unwrap(), 0);
+ assert_eq!(stream.read(&mut []).unwrap(), 0);
+}
+
run_test!(get_peer_certificate, |method, stream| {
let ctx = SslContext::builder(method).unwrap();
let stream = Ssl::new(&ctx.build()).unwrap().connect(stream).unwrap();