fd: effectively revert r305091

Turns out fd_lastfile can survive being -1 for some processes, giving
incorrect results with the cast.

Noted by: cem
This commit is contained in:
mjg 2016-08-31 12:29:04 +00:00
parent 7526e12121
commit 43009b0cad

View File

@ -201,7 +201,7 @@ fget_locked(struct filedesc *fdp, int fd)
FILEDESC_LOCK_ASSERT(fdp);
if ((u_int)fd > fdp->fd_lastfile)
if (fd < 0 || fd > fdp->fd_lastfile)
return (NULL);
return (fdp->fd_ofiles[fd].fde_file);
@ -213,7 +213,7 @@ fdeget_locked(struct filedesc *fdp, int fd)
FILEDESC_LOCK_ASSERT(fdp);
if ((u_int)fd > fdp->fd_lastfile)
if (fd < 0 || fd > fdp->fd_lastfile)
return (NULL);
return (&fdp->fd_ofiles[fd]);