Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpthread Check thread->pt_magic with PT_MAGIC promptly



details:   https://anonhg.NetBSD.org/src/rev/df9946c9dccf
branches:  trunk
changeset: 744322:df9946c9dccf
user:      kamil <kamil%NetBSD.org@localhost>
date:      Wed Jan 29 16:34:09 2020 +0000

description:
Check thread->pt_magic with PT_MAGIC promptly

diffstat:

 lib/libpthread/pthread_misc.c |  22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diffs (78 lines):

diff -r 720647f97b49 -r df9946c9dccf lib/libpthread/pthread_misc.c
--- a/lib/libpthread/pthread_misc.c     Wed Jan 29 16:24:21 2020 +0000
+++ b/lib/libpthread/pthread_misc.c     Wed Jan 29 16:34:09 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_misc.c,v 1.16 2020/01/13 18:22:56 ad Exp $     */
+/*     $NetBSD: pthread_misc.c,v 1.17 2020/01/29 16:34:09 kamil Exp $  */
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_misc.c,v 1.16 2020/01/13 18:22:56 ad Exp $");
+__RCSID("$NetBSD: pthread_misc.c,v 1.17 2020/01/29 16:34:09 kamil Exp $");
 
 #include <errno.h>
 #include <string.h>
@@ -61,6 +61,9 @@
 pthread_getschedparam(pthread_t thread, int *policy, struct sched_param *param)
 {
 
+       pthread__error(EINVAL, "Invalid thread",
+           thread->pt_magic == PT_MAGIC);
+
        if (pthread__find(thread) != 0)
                return ESRCH;
 
@@ -76,6 +79,9 @@
 {
        struct sched_param sp;
 
+       pthread__error(EINVAL, "Invalid thread",
+           thread->pt_magic == PT_MAGIC);
+
        if (pthread__find(thread) != 0)
                return ESRCH;
 
@@ -90,6 +96,9 @@
 pthread_getaffinity_np(pthread_t thread, size_t size, cpuset_t *cpuset)
 {
 
+       pthread__error(EINVAL, "Invalid thread",
+           thread->pt_magic == PT_MAGIC);
+
        if (pthread__find(thread) != 0)
                return ESRCH;
 
@@ -103,6 +112,9 @@
 pthread_setaffinity_np(pthread_t thread, size_t size, cpuset_t *cpuset)
 {
 
+       pthread__error(EINVAL, "Invalid thread",
+           thread->pt_magic == PT_MAGIC);
+
        if (pthread__find(thread) != 0)
                return ESRCH;
 
@@ -117,6 +129,9 @@
 {
        struct sched_param sp;
 
+       pthread__error(EINVAL, "Invalid thread",
+           thread->pt_magic == PT_MAGIC);
+
        if (pthread__find(thread) != 0)
                return ESRCH;
 
@@ -131,6 +146,9 @@
 pthread_kill(pthread_t thread, int sig)
 {
 
+       pthread__error(EINVAL, "Invalid thread",
+           thread->pt_magic == PT_MAGIC);
+
        if ((sig < 0) || (sig >= _NSIG))
                return EINVAL;
        if (pthread__find(thread) != 0)



Home | Main Index | Thread Index | Old Index