diff options
author | jsing <> | 2019-04-01 15:58:02 +0000 |
---|---|---|
committer | jsing <> | 2019-04-01 15:58:02 +0000 |
commit | 124072cef0c06581ae5bb8581be095c92b65e802 (patch) | |
tree | 968d23aa68db9b19e12bd8f87dac1683253ac622 /src/lib/libtls/tls.c | |
parent | 9552538f07c2d19c99c3229f037712f6dfa1c550 (diff) | |
download | openbsd-124072cef0c06581ae5bb8581be095c92b65e802.tar.gz openbsd-124072cef0c06581ae5bb8581be095c92b65e802.tar.bz2 openbsd-124072cef0c06581ae5bb8581be095c92b65e802.zip |
Add a mutex to guard reference counting for tls_config.
This makes libtls more friendly for multithreaded use - otherwise we can
end up with incorrect refcounts and end up freeing when we should not be
(or not freeing when we should be).
ok beck@
Diffstat (limited to 'src/lib/libtls/tls.c')
-rw-r--r-- | src/lib/libtls/tls.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/lib/libtls/tls.c b/src/lib/libtls/tls.c index bf1d9da81e..46ed8180d1 100644 --- a/src/lib/libtls/tls.c +++ b/src/lib/libtls/tls.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls.c,v 1.82 2018/11/29 14:24:23 tedu Exp $ */ | 1 | /* $OpenBSD: tls.c,v 1.83 2019/04/01 15:58:02 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -256,7 +256,9 @@ tls_configure(struct tls *ctx, struct tls_config *config) | |||
256 | if (config == NULL) | 256 | if (config == NULL) |
257 | config = tls_config_default; | 257 | config = tls_config_default; |
258 | 258 | ||
259 | pthread_mutex_lock(&config->mutex); | ||
259 | config->refcount++; | 260 | config->refcount++; |
261 | pthread_mutex_unlock(&config->mutex); | ||
260 | 262 | ||
261 | tls_config_free(ctx->config); | 263 | tls_config_free(ctx->config); |
262 | 264 | ||