summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_ffs
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2008-02-26 03:08:22 +0000
committerdelphij <delphij@FreeBSD.org>2008-02-26 03:08:22 +0000
commit62e9740096cfec82b67181d1863fb2b7ce3daa01 (patch)
tree800a059e46018ee1ca4f0712bc3ec8755b7a57ed /sbin/fsck_ffs
parentdb686b518eda3e59a2fb94866f837386fbabca9d (diff)
downloadFreeBSD-src-62e9740096cfec82b67181d1863fb2b7ce3daa01.zip
FreeBSD-src-62e9740096cfec82b67181d1863fb2b7ce3daa01.tar.gz
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.
Diffstat (limited to 'sbin/fsck_ffs')
-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 f728877..9bfc95d 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",
OpenPOWER on IntegriCloud