diff options
| author | kamil <kamil@NetBSD.org> | 2020-02-08 17:06:03 +0000 |
|---|---|---|
| committer | kamil <kamil@NetBSD.org> | 2020-02-08 17:06:03 +0000 |
| commit | 253ea5f83bd660b18b308d2bd8ef6a6704703d94 (patch) | |
| tree | 33cc75418725ea939aa29a662da84d87ae9bb680 /lib/libpthread | |
| parent | 42905a9c0ad2fa25ede096e56db612dcfd98d454 (diff) | |
Change the behavior of pthread_equal()
On error when not aborting, do not return EINVAL as it has a side effect
of being interpreted as matching threads. For invalid threads return
unmatched.
Check pthreads for NULL, before accessing pt_magic field. This avoids
faults on comparision with a NULL pointer.
This behavior is in the scope of UB, but should be easier to deal with
buggy software.
Diffstat (limited to 'lib/libpthread')
| -rw-r--r-- | lib/libpthread/pthread.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/libpthread/pthread.c b/lib/libpthread/pthread.c index ce3fa7ca80d..b4e5a601537 100644 --- a/lib/libpthread/pthread.c +++ b/lib/libpthread/pthread.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread.c,v 1.163 2020/02/05 14:56:04 ryoon Exp $ */ +/* $NetBSD: pthread.c,v 1.164 2020/02/08 17:06:03 kamil Exp $ */ /*- * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008, 2020 @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: pthread.c,v 1.163 2020/02/05 14:56:04 ryoon Exp $"); +__RCSID("$NetBSD: pthread.c,v 1.164 2020/02/08 17:06:03 kamil Exp $"); #define __EXPOSE_STACK 1 @@ -770,11 +770,11 @@ pthread_equal(pthread_t t1, pthread_t t2) if (__predict_false(__uselibcstub)) return __libc_thr_equal_stub(t1, t2); - pthread__error(EINVAL, "Invalid thread", - t1->pt_magic == PT_MAGIC); + pthread__error(0, "Invalid thread", + (t1 != NULL) && (t1->pt_magic == PT_MAGIC)); - pthread__error(EINVAL, "Invalid thread", - t2->pt_magic == PT_MAGIC); + pthread__error(0, "Invalid thread", + (t2 != NULL) && (t2->pt_magic == PT_MAGIC)); /* Nothing special here. */ return (t1 == t2); |
