aboutsummaryrefslogtreecommitdiff
path: root/openssl-sys-extras/src
diff options
context:
space:
mode:
authorGeoffroy Couprie <[email protected]>2015-12-03 12:26:55 +0100
committerGeoffroy Couprie <[email protected]>2015-12-03 12:26:55 +0100
commit6850c810d32a11330c9b1dd4889b447fa8434c36 (patch)
tree71cba316629d2b8ba9c22a9be10acc2d4a99a9e2 /openssl-sys-extras/src
parentMake shims for SSL_CTX_ctrl and SSL_CTX_callback_ctrl macro wrappers (diff)
downloadrust-openssl-6850c810d32a11330c9b1dd4889b447fa8434c36.tar.xz
rust-openssl-6850c810d32a11330c9b1dd4889b447fa8434c36.zip
Increment SSL_CTX's reference count in Ssl::get_ssl_context()
Without this, whenever the returned SslContext is released, the refcount of the underlying SSL_CTX will decrease and it will be freed too soon
Diffstat (limited to 'openssl-sys-extras/src')
-rw-r--r--openssl-sys-extras/src/lib.rs2
-rw-r--r--openssl-sys-extras/src/openssl_shim.c5
2 files changed, 7 insertions, 0 deletions
diff --git a/openssl-sys-extras/src/lib.rs b/openssl-sys-extras/src/lib.rs
index f17c7fd5..69a1fee9 100644
--- a/openssl-sys-extras/src/lib.rs
+++ b/openssl-sys-extras/src/lib.rs
@@ -69,4 +69,6 @@ extern {
pub fn SSL_CTX_set_tlsext_servername_callback(ssl: *mut SSL_CTX, callback: Option<extern fn()>);
#[link_name = "SSL_CTX_set_tlsext_servername_arg_shim"]
pub fn SSL_CTX_set_tlsext_servername_arg(ssl: *mut SSL_CTX, arg: *const c_void);
+ #[link_name = "SSL_CTX_increment_refcount_shim"]
+ pub fn SSL_CTX_increment_refcount(ssl: *mut SSL_CTX) -> c_long;
}
diff --git a/openssl-sys-extras/src/openssl_shim.c b/openssl-sys-extras/src/openssl_shim.c
index 302e539a..51630daf 100644
--- a/openssl-sys-extras/src/openssl_shim.c
+++ b/openssl-sys-extras/src/openssl_shim.c
@@ -123,6 +123,11 @@ long SSL_CTX_set_tlsext_servername_arg_shim(SSL_CTX *ctx, void* arg) {
return SSL_CTX_set_tlsext_servername_arg(ctx, arg);
}
+long SSL_CTX_increment_refcount_shim(SSL_CTX *ctx) {
+ int i = CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX);
+ return i;
+}
+
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
int SSL_CTX_set_ecdh_auto_shim(SSL_CTX *ctx, int onoff) {
return SSL_CTX_set_ecdh_auto(ctx, onoff);