diff options
author | 2019-04-01 15:58:02 +0000 | |
---|---|---|
committer | 2019-04-01 15:58:02 +0000 | |
commit | bebb943a196415fbcce9ded465749b2710c53245 (patch) | |
tree | a36d996845869d6fa9ca0affd312e17ee97054cc /lib/libtls/tls.c | |
parent | Implement a print function for BIGNUM_it. (diff) | |
download | wireguard-openbsd-bebb943a196415fbcce9ded465749b2710c53245.tar.xz wireguard-openbsd-bebb943a196415fbcce9ded465749b2710c53245.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 'lib/libtls/tls.c')
-rw-r--r-- | lib/libtls/tls.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libtls/tls.c b/lib/libtls/tls.c index bf1d9da81ea..46ed8180d10 100644 --- a/lib/libtls/tls.c +++ b/lib/libtls/tls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls.c,v 1.82 2018/11/29 14:24:23 tedu Exp $ */ +/* $OpenBSD: tls.c,v 1.83 2019/04/01 15:58:02 jsing Exp $ */ /* * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> * @@ -256,7 +256,9 @@ tls_configure(struct tls *ctx, struct tls_config *config) if (config == NULL) config = tls_config_default; + pthread_mutex_lock(&config->mutex); config->refcount++; + pthread_mutex_unlock(&config->mutex); tls_config_free(ctx->config); |