aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatarLibravatar daurnimator <quae@daurnimator.com> 2018-03-27 15:14:15 +1100
committerLibravatarLibravatar daurnimator <quae@daurnimator.com> 2018-03-27 15:14:15 +1100
commit1ae707300bf99805bd93744020c60cf60cdc2294 (patch)
treed8133e707a56631c4811ce3c7a43d1064424cba0 /src
parent5be1b44a6a60f32c660cc4ee09d60e676cd8c81a (diff)
downloadluaossl-1ae707300bf99805bd93744020c60cf60cdc2294.tar.gz
luaossl-1ae707300bf99805bd93744020c60cf60cdc2294.tar.bz2
luaossl-1ae707300bf99805bd93744020c60cf60cdc2294.zip
src/openssl.c: Fix SSL_CTX_set1_cert_store refcounting issues
Closes #124
Diffstat (limited to 'src')
-rw-r--r--src/openssl.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/openssl.c b/src/openssl.c
index 5ff80fe..f821170 100644
--- a/src/openssl.c
+++ b/src/openssl.c
@@ -1856,18 +1856,16 @@ static void (compat_X509_STORE_free)(X509_STORE *store) {
#endif
#if !HAVE_SSL_CTX_SET1_CERT_STORE
-#if !HAVE_SSL_CTX_CERT_STORE || !HAVE_X509_STORE_REFERENCES
-#define SSL_CTX_set1_cert_store(ctx, store) \
- SSL_CTX_set_cert_store((ctx), (store))
-#else
-#define SSL_CTX_set1_cert_store(ctx, store) \
- compat_SSL_CTX_set1_cert_store((ctx), (store))
-/* to support preprocessor detection below */
-#define compat_SSL_CTX_set1_cert_store(ctx, store) \
+#define SSL_CTX_set1_cert_store(ctx, store) \
compat_SSL_CTX_set1_cert_store((ctx), (store))
static void (compat_SSL_CTX_set1_cert_store)(SSL_CTX *ctx, X509_STORE *store) {
+#if !HAVE_SSL_CTX_CERT_STORE || !HAVE_X509_STORE_REFERENCES
+ if (store != NULL)
+ X509_STORE_up_ref(store);
+ SSL_CTX_set_cert_store(ctx, store);
+#else
int n;
/*
@@ -1885,8 +1883,9 @@ static void (compat_SSL_CTX_set1_cert_store)(SSL_CTX *ctx, X509_STORE *store) {
if (n == store->references)
CRYPTO_add(&store->references, 1, CRYPTO_LOCK_X509_STORE);
-} /* compat_SSL_CTX_set1_cert_store() */
#endif
+} /* compat_SSL_CTX_set1_cert_store() */
+
#endif
#if HAVE_SSL_CTX_CERT_STORE