diff options
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/sys_generic.c | 17 | ||||
-rw-r--r-- | sys/kern/uipc_usrreq.c | 12 |
2 files changed, 11 insertions, 18 deletions
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index ea62a488a66..575e4fc58c0 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_generic.c,v 1.31 2001/11/14 19:47:07 deraadt Exp $ */ +/* $OpenBSD: sys_generic.c,v 1.32 2002/02/02 16:05:58 art Exp $ */ /* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */ /* @@ -787,8 +787,7 @@ selscan(p, ibits, obits, nfd, retval) bits = pibits->fds_bits[i/NFDBITS]; while ((j = ffs(bits)) && (fd = i + --j) < nfd) { bits &= ~(1 << j); - fp = fdp->fd_ofiles[fd]; - if (fp == NULL) + if ((fp = fd_getfile(fdp, fd)) == NULL) return (EBADF); if ((*fp->f_ops->fo_select)(fp, flag[msk], p)) { FD_SET(fd, pobits); @@ -884,19 +883,11 @@ pollscan(p, pl, nfd, retval) */ for (i = 0; i < nfd; i++) { /* Check the file descriptor. */ - if (pl[i].fd < 0) - continue; - if (pl[i].fd >= fdp->fd_nfiles) { - pl[i].revents = POLLNVAL; - n++; - continue; - } else if (pl[i].fd < 0) { + if (pl[i].fd < 0) { pl[i].revents = 0; continue; } - - fp = fdp->fd_ofiles[pl[i].fd]; - if (fp == NULL) { + if ((fp = fd_getfile(fdp, pl[i].fd)) == NULL) { pl[i].revents = POLLNVAL; n++; continue; diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 46b675b3c96..0d04d9a80d5 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_usrreq.c,v 1.15 2001/10/26 12:03:27 art Exp $ */ +/* $OpenBSD: uipc_usrreq.c,v 1.16 2002/02/02 16:05:58 art Exp $ */ /* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */ /* @@ -750,11 +750,12 @@ unp_internalize(control, p) oldfds = (cm->cmsg_len - sizeof (*cm)) / sizeof (int); ip = (int *)(cm + 1); for (i = 0; i < oldfds; i++) { + struct file *fp; fd = *ip++; - if (fd_getfile(fdp, fd) == NULL) + if ((fp = fd_getfile(fdp, fd)) == NULL) return (EBADF); - if (fdp->fd_ofiles[fd]->f_count == LONG_MAX-2 || - fdp->fd_ofiles[fd]->f_msgcount == LONG_MAX-2) + if (fp->f_count == LONG_MAX-2 || + fp->f_msgcount == LONG_MAX-2) return (EDEADLK); } ip = (int *)(cm + 1); @@ -766,7 +767,8 @@ unp_internalize(control, p) for (i = 0; i < oldfds; i++) { bcopy(ip, &fd, sizeof fd); ip++; - fp = fdp->fd_ofiles[fd]; + fp = fd_getfile(fdp, fd); + /* XXX - are ew really sure that this will never fail? */ bcopy(&fp, rp, sizeof fp); rp++; fp->f_count++; |