From owner-freebsd-bugs Mon Apr 15 15:00:10 1996 Return-Path: owner-bugs Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id PAA11620 for bugs-outgoing; Mon, 15 Apr 1996 15:00:10 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id PAA11602 Mon, 15 Apr 1996 15:00:07 -0700 (PDT) Resent-Date: Mon, 15 Apr 1996 15:00:07 -0700 (PDT) Resent-Message-Id: <199604152200.PAA11602@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, jraynard@dial.pipex.com Received: from vent.pipex.net (root@vent.pipex.net [158.43.128.5]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id OAA11407 for ; Mon, 15 Apr 1996 14:56:02 -0700 (PDT) Received: from me by vent.pipex.net (8.6.12/PIPEX simple 1.20) id WAA18178; Mon, 15 Apr 1996 22:54:27 +0100 Received: (from jraynard@localhost) by me (8.6.12/8.6.12) id SAA01603; Mon, 15 Apr 1996 18:29:55 GMT Message-Id: <199604151829.SAA01603@me> Date: Mon, 15 Apr 1996 18:29:55 GMT From: James Raynard Reply-To: jraynard@dial.pipex.com To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: kern/1144: sig{add, del}set and sigismember fns don't check signo Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >Number: 1144 >Category: kern >Synopsis: sig{add, del}set and sigismember fns don't check signo >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Apr 15 15:00:06 PDT 1996 >Last-Modified: >Originator: James Raynard >Organization: A FreeBSD Box >Release: FreeBSD 2.1-STABLE i386 >Environment: FreeBSD-2.1.0-RELEASE >Description: According to Stevens (advanced Programming in the Unix Environment, p. 292), POSIX.1 requires that sigaddset, sigdelset and sigismember check the signal number argument for validity and set errno if it is invalid. FreeBSD's implementation of these functions does not comply with this. >How-To-Repeat: Look at /usr/src/lib/libc/gen/sigsetops.c and /usr/include/signal.h. >Fix: The following patch to /usr/src/lib/libc/gen/sigsetops.c is based on code given by Stevens to demonstrate how to do this if they are implemented as functions. However, FreeBSD also implements them as macros in /usr/include/signal.h, the function versions only being available if the macros are #undef'd. Obviously the macros would be much harder to fix (are they actually necessary, BTW?) *** sigsetops.c.old Mon Apr 15 17:39:46 1996 --- sigsetops.c Mon Apr 15 17:54:19 1996 *************** *** 38,43 **** --- 38,44 ---- #endif /* LIBC_SCCS and not lint */ #include + #include #undef sigemptyset #undef sigfillset *************** *** 45,50 **** --- 46,53 ---- #undef sigdelset #undef sigismember + #define SIGBAD(signo) ((signo) <= 0 || (signo) >= NSIG) + sigemptyset(set) sigset_t *set; { *************** *** 63,68 **** --- 66,73 ---- sigset_t *set; int signo; { + if (SIGBAD (signo)) { errno = EINVAL; return (-1); } + *set |= sigmask(signo); return (0); } *************** *** 71,76 **** --- 76,83 ---- sigset_t *set; int signo; { + if (SIGBAD (signo)) { errno = EINVAL; return (-1); } + *set &= ~sigmask(signo); return (0); } *************** *** 79,83 **** --- 86,92 ---- const sigset_t *set; int signo; { + if (SIGBAD (signo)) { errno = EINVAL; return (-1); } + return ((*set & ~sigmask(signo)) != 0); } >Audit-Trail: >Unformatted: