summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2016-10-15 13:39:47 -0700
committerSteven Fackler <sfackler@gmail.com>2016-10-15 13:39:47 -0700
commit228b8fbc5b5567f19b66754f589d47851817c411 (patch)
tree483cb4c310c6db8b176a70bb88bb205afabdd19d
parentd7501d42857363121f398aaad95dc6a8fdced80e (diff)
downloadrust-openssl-228b8fbc5b5567f19b66754f589d47851817c411.zip
Correctly bind BIO_new_mem_buf
-rw-r--r--openssl-sys/src/lib.rs3
-rw-r--r--openssl/src/bio.rs11
-rw-r--r--systest/build.rs4
3 files changed, 13 insertions, 5 deletions
diff --git a/openssl-sys/src/lib.rs b/openssl-sys/src/lib.rs
index 6fe44750..67b93f25 100644
--- a/openssl-sys/src/lib.rs
+++ b/openssl-sys/src/lib.rs
@@ -344,6 +344,9 @@ extern {
pub fn BIO_new_socket(sock: c_int, close_flag: c_int) -> *mut BIO;
pub fn BIO_read(b: *mut BIO, buf: *mut c_void, len: c_int) -> c_int;
pub fn BIO_write(b: *mut BIO, buf: *const c_void, len: c_int) -> c_int;
+ #[cfg(ossl101)]
+ pub fn BIO_new_mem_buf(buf: *mut c_void, len: c_int) -> *mut BIO;
+ #[cfg(not(ossl101))]
pub fn BIO_new_mem_buf(buf: *const c_void, len: c_int) -> *mut BIO;
pub fn BIO_set_flags(b: *mut BIO, flags: c_int);
pub fn BIO_clear_flags(b: *mut BIO, flags: c_int);
diff --git a/openssl/src/bio.rs b/openssl/src/bio.rs
index 0d82a6c3..22d2cee3 100644
--- a/openssl/src/bio.rs
+++ b/openssl/src/bio.rs
@@ -22,7 +22,7 @@ impl<'a> MemBioSlice<'a> {
assert!(buf.len() <= c_int::max_value() as usize);
let bio = unsafe {
- try_ssl_null!(ffi::BIO_new_mem_buf(buf.as_ptr() as *const _, buf.len() as c_int))
+ try_ssl_null!(BIO_new_mem_buf(buf.as_ptr() as *const _, buf.len() as c_int))
};
Ok(MemBioSlice(bio, PhantomData))
@@ -65,3 +65,12 @@ impl MemBio {
}
}
}
+
+#[cfg(not(ossl101))]
+use ffi::BIO_new_mem_buf;
+
+#[cfg(ossl101)]
+#[allow(bad_style)]
+unsafe fn BIO_new_mem_buf(buf: *const ::libc::c_void, len: ::libc::c_int) -> *mut ffi::BIO {
+ ffi::BIO_new_mem_buf(buf as *mut _, len)
+}
diff --git a/systest/build.rs b/systest/build.rs
index 94c5534e..8fac5536 100644
--- a/systest/build.rs
+++ b/systest/build.rs
@@ -81,10 +81,6 @@ fn main() {
s == "X509V3_EXT_conf_nid" || // weird lhash first param
s == "X509V3_EXT_conf" || // weird lhash first param
- // one parameter is `const` in OpenSSL 1.0.1, no need for a new
- // definition or a new file here.
- (s == "BIO_new_mem_buf" && env::var("DEP_OPENSSL_IS_101").is_ok()) ||
-
// Skip some functions with function pointers on windows, not entirely
// sure how to get them to work out...
(target.contains("windows") && {