summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2011-07-02 17:12:02 +0000
committertedu <tedu@openbsd.org>2011-07-02 17:12:02 +0000
commit1d3035ec0caaa19eb575b24ed88f8364d27b3cd2 (patch)
tree57b71f2dda272a36e9e5681a865cffe4745601f8 /lib
parentUse getvnode() instead of implementing our own file descriptor handling (diff)
downloadwireguard-openbsd-1d3035ec0caaa19eb575b24ed88f8364d27b3cd2.tar.xz
wireguard-openbsd-1d3035ec0caaa19eb575b24ed88f8364d27b3cd2.zip
pthread_key_delete should delete the data, so it's not reused by
a later pthread_key_create. bug report from Henry Precheur. ok guenther mikeb
Diffstat (limited to 'lib')
-rw-r--r--lib/libpthread/uthread/uthread_spec.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/libpthread/uthread/uthread_spec.c b/lib/libpthread/uthread/uthread_spec.c
index 1d6ee001035..eecf07d10e4 100644
--- a/lib/libpthread/uthread/uthread_spec.c
+++ b/lib/libpthread/uthread/uthread_spec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_spec.c,v 1.9 2007/07/20 22:34:40 kettenis Exp $ */
+/* $OpenBSD: uthread_spec.c,v 1.10 2011/07/02 17:12:02 tedu Exp $ */
/*
* Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
* All rights reserved.
@@ -78,6 +78,7 @@ int
pthread_key_delete(pthread_key_t key)
{
int ret = 0;
+ pthread_t pthread;
if (key < PTHREAD_KEYS_MAX) {
/* Lock the key table entry: */
@@ -88,8 +89,19 @@ pthread_key_delete(pthread_key_t key)
else
ret = EINVAL;
+ _thread_kern_sig_defer();
+ TAILQ_FOREACH(pthread, &_thread_list, tle) {
+ if (pthread->specific_data[key]) {
+ pthread->specific_data[key] = NULL;
+ pthread->specific_data_count--;
+ }
+
+ }
+ _thread_kern_sig_undefer();
+
/* Unlock the key table entry: */
_SPINUNLOCK(&key_table[key].lock);
+
} else
ret = EINVAL;
return (ret);