diff options
author | davidxu <davidxu@FreeBSD.org> | 2013-04-18 05:56:00 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2013-04-18 05:56:00 +0000 |
commit | 4144588ba6b4591b2185d02ac40aab988bf7fc8e (patch) | |
tree | e4b6f6fc2374b0bd8c25966532484f8527e565ac /lib/libthr/thread/thr_sig.c | |
parent | aaf865752d7ec3c065524e8a254d5cd38cd2dbc2 (diff) | |
download | FreeBSD-src-4144588ba6b4591b2185d02ac40aab988bf7fc8e.zip FreeBSD-src-4144588ba6b4591b2185d02ac40aab988bf7fc8e.tar.gz |
Avoid copying memory if SIGCANCEL is not masked.
Diffstat (limited to 'lib/libthr/thread/thr_sig.c')
-rw-r--r-- | lib/libthr/thread/thr_sig.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/libthr/thread/thr_sig.c b/lib/libthr/thread/thr_sig.c index d2be994..420d99b 100644 --- a/lib/libthr/thread/thr_sig.c +++ b/lib/libthr/thread/thr_sig.c @@ -732,8 +732,12 @@ _setcontext(const ucontext_t *ucp) { ucontext_t uc; + if (ucp == NULL) + return (EINVAL); + if (!SIGISMEMBER(uc.uc_sigmask, SIGCANCEL)) + return __sys_setcontext(ucp); (void) memcpy(&uc, ucp, sizeof(uc)); - remove_thr_signals(&uc.uc_sigmask); + SIGDELSET(uc.uc_sigmask, SIGCANCEL); return __sys_setcontext(&uc); } @@ -743,7 +747,13 @@ _swapcontext(ucontext_t *oucp, const ucontext_t *ucp) { ucontext_t uc; - (void) memcpy(&uc, ucp, sizeof(uc)); - remove_thr_signals(&uc.uc_sigmask); - return __sys_swapcontext(oucp, &uc); + if (oucp == NULL || ucp == NULL) + return (EINVAL); + if (SIGISMEMBER(ucp->uc_sigmask, SIGCANCEL)) { + stdout_debug("remove SIGCANCEL\n"); + (void) memcpy(&uc, ucp, sizeof(uc)); + SIGDELSET(uc.uc_sigmask, SIGCANCEL); + ucp = &uc; + } + return __sys_swapcontext(oucp, ucp); } |