From owner-svn-src-all@FreeBSD.ORG Thu Jul 22 09:14:19 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3DDA2106566B; Thu, 22 Jul 2010 09:14:19 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 131D58FC14; Thu, 22 Jul 2010 09:14:19 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o6M9EIjJ000487; Thu, 22 Jul 2010 09:14:18 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o6M9EIDN000485; Thu, 22 Jul 2010 09:14:18 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201007220914.o6M9EIDN000485@svn.freebsd.org> From: Konstantin Belousov Date: Thu, 22 Jul 2010 09:14:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r210370 - head/lib/libc/compat-43 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Jul 2010 09:14:19 -0000 Author: kib Date: Thu Jul 22 09:14:18 2010 New Revision: 210370 URL: http://svn.freebsd.org/changeset/base/210370 Log: Verify return value of the sigset manipulation functions to catch invalid signal numbers [1]. Use consistent style of not assigning the return value to a local variable. Reported by: Garrett Cooper [1] MFC after: 1 week Modified: head/lib/libc/compat-43/sigcompat.c Modified: head/lib/libc/compat-43/sigcompat.c ============================================================================== --- head/lib/libc/compat-43/sigcompat.c Thu Jul 22 09:13:49 2010 (r210369) +++ head/lib/libc/compat-43/sigcompat.c Thu Jul 22 09:14:18 2010 (r210370) @@ -112,16 +112,11 @@ int xsi_sigpause(int sig) { sigset_t set; - int error; - if (!_SIG_VALID(sig)) { - errno = EINVAL; + if (_sigprocmask(SIG_BLOCK, NULL, &set) == -1) + return (-1); + if (sigdelset(&set, sig) == -1) return (-1); - } - error = _sigprocmask(SIG_BLOCK, NULL, &set); - if (error != 0) - return (error); - sigdelset(&set, sig); return (_sigsuspend(&set)); } @@ -131,7 +126,8 @@ sighold(int sig) sigset_t set; sigemptyset(&set); - sigaddset(&set, sig); + if (sigaddset(&set, sig) == -1) + return (-1); return (_sigprocmask(SIG_BLOCK, &set, NULL)); } @@ -151,7 +147,8 @@ sigrelse(int sig) sigset_t set; sigemptyset(&set); - sigaddset(&set, sig); + if (sigaddset(&set, sig) == -1) + return (-1); return (_sigprocmask(SIG_UNBLOCK, &set, NULL)); } @@ -160,35 +157,30 @@ void { sigset_t set, pset; struct sigaction sa, psa; - int error; sigemptyset(&set); - sigaddset(&set, sig); - error = _sigprocmask(SIG_BLOCK, NULL, &pset); - if (error == -1) + if (sigaddset(&set, sig) == -1) + return (SIG_ERR); + if (_sigprocmask(SIG_BLOCK, NULL, &pset) == -1) return (SIG_ERR); if ((__sighandler_t *)disp == SIG_HOLD) { - error = _sigprocmask(SIG_BLOCK, &set, &pset); - if (error == -1) + if (_sigprocmask(SIG_BLOCK, &set, &pset) == -1) return (SIG_ERR); if (sigismember(&pset, sig)) return (SIG_HOLD); else { - error = _sigaction(sig, NULL, &psa); - if (error == -1) + if (_sigaction(sig, NULL, &psa) == -1) return (SIG_ERR); return (psa.sa_handler); } } else { - error = _sigprocmask(SIG_UNBLOCK, &set, &pset); - if (error == -1) + if (_sigprocmask(SIG_UNBLOCK, &set, &pset) == -1) return (SIG_ERR); } bzero(&sa, sizeof(sa)); sa.sa_handler = disp; - error = _sigaction(sig, &sa, &psa); - if (error == -1) + if (_sigaction(sig, &sa, &psa) == -1) return (SIG_ERR); if (sigismember(&pset, sig)) return (SIG_HOLD);