- In sysctl_kern_file skip fdps with negative lastfiles. This can

happen if there are no files open.  Accounting for these can
   eventually return a negative value for olenp causing sysctl to
   crash with a bad malloc.

Reported by:	Pawel Worach <pawel.worach@gmail.com>
This commit is contained in:
Jeff Roberson 2008-01-03 01:26:59 +00:00
parent 9a62623a15
commit a57decdf32

View File

@ -2392,7 +2392,8 @@ sysctl_kern_file(SYSCTL_HANDLER_ARGS)
if (fdp == NULL)
continue;
/* overestimates sparse tables. */
n += fdp->fd_lastfile;
if (fdp->fd_lastfile > 0)
n += fdp->fd_lastfile;
fddrop(fdp);
}
sx_sunlock(&allproc_lock);