From 500c969f059dc1b12dc3809d270cb169abbd57d3 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Wed, 9 Mar 2011 20:31:06 -0500 Subject: [PATCH] fix error handling for pthread_sigmask it must return errno, not -1, and should reject invalud values for how. --- src/signal/sigprocmask.c | 6 +++++- src/thread/pthread_sigmask.c | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/thread/pthread_sigmask.c diff --git a/src/signal/sigprocmask.c b/src/signal/sigprocmask.c index 1bc5baa6..96d08478 100644 --- a/src/signal/sigprocmask.c +++ b/src/signal/sigprocmask.c @@ -1,4 +1,5 @@ #include +#include #include "syscall.h" #include "libc.h" #include "pthread_impl.h" @@ -11,6 +12,10 @@ int __libc_sigprocmask(int how, const sigset_t *set, sigset_t *old) int __sigprocmask(int how, const sigset_t *set, sigset_t *old) { sigset_t tmp; + if (how > 2U) { + errno = EINVAL; + return -1; + } /* Disallow blocking thread control signals */ if (set && how != SIG_UNBLOCK) { tmp = *set; @@ -22,4 +27,3 @@ int __sigprocmask(int how, const sigset_t *set, sigset_t *old) } weak_alias(__sigprocmask, sigprocmask); -weak_alias(__sigprocmask, pthread_sigmask); diff --git a/src/thread/pthread_sigmask.c b/src/thread/pthread_sigmask.c new file mode 100644 index 00000000..6cc21d22 --- /dev/null +++ b/src/thread/pthread_sigmask.c @@ -0,0 +1,10 @@ +#include +#include +#include + +int pthread_sigmask(int how, const sigset_t *set, sigset_t *old) +{ + int ret = sigprocmask(how, set, old); + if (ret) return errno; + return 0; +} -- 2.25.1