From owner-freebsd-bugs Sat Nov 7 22:09:59 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id WAA05688 for freebsd-bugs-outgoing; Sat, 7 Nov 1998 22:09:59 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id WAA05681 for ; Sat, 7 Nov 1998 22:09:58 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id WAA14235; Sat, 7 Nov 1998 22:10:00 -0800 (PST) Received: from alive.znep.com (207-178-54-226.go2net.com [207.178.54.226]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id WAA05030 for ; Sat, 7 Nov 1998 22:03:42 -0800 (PST) (envelope-from marcs@alive.znep.com) Received: (from marcs@localhost) by alive.znep.com (8.9.1/8.9.1) id VAA04518; Sat, 7 Nov 1998 21:59:35 -0800 (PST) (envelope-from marcs) Message-Id: <199811080559.VAA04518@alive.znep.com> Date: Sat, 7 Nov 1998 21:59:35 -0800 (PST) From: marcs@znep.com Reply-To: marcs@znep.com To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: kern/8599: poll(2) sets POLLNVAL for negative descriptors Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 8599 >Category: kern >Synopsis: poll(2) sets POLLNVAL for negative descriptors >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Nov 7 22:10:00 PST 1998 >Last-Modified: >Originator: Marc Slemko >Organization: >Release: FreeBSD 3.0-CURRENT i386 >Environment: FreeBSD alive.znep.com 3.0-CURRENT FreeBSD 3.0-CURRENT #8: Sat Nov 7 21:26:59 PST 1998 marcs@alive.znep.com:/usr/src/sys/compile/ALIVE i386 3.0-current as of a few days ago. >Description: poll(2) sets POLLNVAL for descriptors passed in that are less than 0. This makes it difficult to do efficient manipulation of the struct pollfd since you can't leave a slot empty. >How-To-Repeat: Set fds[n].fd = -1 and do a poll on it. It treats it as an POLLNVAL when it should ignore it. >Fix: I have no idea why fds->fd was being cast to a u_int. Index: sys_generic.c =================================================================== RCS file: /home/ncvs/src/sys/kern/sys_generic.c,v retrieving revision 1.41 diff -u -r1.41 sys_generic.c --- sys_generic.c 1998/09/05 14:30:11 1.41 +++ sys_generic.c 1998/11/08 05:26:43 @@ -793,9 +793,11 @@ int n = 0; for (i = 0; i < nfd; i++, fds++) { - if ((u_int)fds->fd >= fdp->fd_nfiles) { + if (fds->fd >= fdp->fd_nfiles) { fds->revents = POLLNVAL; n++; + } else if (fds->fd < 0) { + fds->revents = 0; } else { fp = fdp->fd_ofiles[fds->fd]; if (fp == 0) { >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message