From 811f1d35ef471cadfb6d935bdf932ac76df39940 Mon Sep 17 00:00:00 2001 From: jeff Date: Thu, 3 Jan 2008 01:26:59 +0000 Subject: - 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 --- sys/kern/kern_descrip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sys/kern/kern_descrip.c') diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 070fac7..d68854e 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -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); -- cgit v1.1