diff options
author | jeff <jeff@FreeBSD.org> | 2008-01-03 01:26:59 +0000 |
---|---|---|
committer | jeff <jeff@FreeBSD.org> | 2008-01-03 01:26:59 +0000 |
commit | 811f1d35ef471cadfb6d935bdf932ac76df39940 (patch) | |
tree | 81eb902582b95f8c33fd320715f7e56d4a709293 /sys/kern/kern_descrip.c | |
parent | 7719fcccbcd3f1197c48ad6c4a9d29efc8e8e362 (diff) | |
download | FreeBSD-src-811f1d35ef471cadfb6d935bdf932ac76df39940.zip FreeBSD-src-811f1d35ef471cadfb6d935bdf932ac76df39940.tar.gz |
- 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>
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r-- | sys/kern/kern_descrip.c | 3 |
1 files changed, 2 insertions, 1 deletions
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); |