Date: Sat, 7 Nov 1998 21:59:35 -0800 (PST) From: marcs@znep.com To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: kern/8599: poll(2) sets POLLNVAL for negative descriptors Message-ID: <199811080559.VAA04518@alive.znep.com>
next in thread | raw e-mail | index | archive | help
>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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199811080559.VAA04518>
