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:
Mateusz Guzik 2016-08-31 12:29:04 +00:00
parent 9007a8679a
commit 44feca2360
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=305124

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]);