aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2008-02-26 03:08:22 +0000
committerXin LI <delphij@FreeBSD.org>2008-02-26 03:08:22 +0000
commit1aaf5f440f1f108374121fd46b29a024fdb1f7f6 (patch)
tree800a059e46018ee1ca4f0712bc3ec8755b7a57ed /sbin
parent33663c724656d32b9381705a6c8d773e92dc4697 (diff)
downloadsrc-1aaf5f440f1f108374121fd46b29a024fdb1f7f6.tar.gz
src-1aaf5f440f1f108374121fd46b29a024fdb1f7f6.zip
In pass1(), cap inosused to fs_ipg rather than allowing arbitrary
number read from cylinder group. Chances that we read a smarshed cylinder group, and we can not 100% trust information it has supplied. fsck_ffs(8) will crash otherwise for some cases.
Notes
Notes: svn path=/head/; revision=176575
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fsck_ffs/pass1.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c
index f72887755ec2..9bfc95df00c6 100644
--- a/sbin/fsck_ffs/pass1.c
+++ b/sbin/fsck_ffs/pass1.c
@@ -93,9 +93,11 @@ pass1(void)
inumber = c * sblock.fs_ipg;
setinodebuf(inumber);
getblk(&cgblk, cgtod(&sblock, c), sblock.fs_cgsize);
- if (sblock.fs_magic == FS_UFS2_MAGIC)
+ if (sblock.fs_magic == FS_UFS2_MAGIC) {
inosused = cgrp.cg_initediblk;
- else
+ if (inosused > sblock.fs_ipg)
+ inosused = sblock.fs_ipg;
+ } else
inosused = sblock.fs_ipg;
if (got_siginfo) {
printf("%s: phase 1: cyl group %d of %d (%d%%)\n",