summaryrefslogtreecommitdiff
path: root/sbin/fsck_ffs/pass1.c
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2009-05-29 07:57:44 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2009-05-29 07:57:44 +0000
commitb7c45891a832024d88a24b9e52e1df61f45fc7e5 (patch)
tree9efa899a2d0a1c8f601e7939f8d412d4d1c98f13 /sbin/fsck_ffs/pass1.c
parentc89a694cc8c38858b71c9bde18b1d54c07e17c8b (diff)
catch funny values of cg_initediblk; make fsck_ffs more robust
against forms of cg header corruption as experienced by todd@; ok millert@
Diffstat (limited to 'sbin/fsck_ffs/pass1.c')
-rw-r--r--sbin/fsck_ffs/pass1.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sbin/fsck_ffs/pass1.c b/sbin/fsck_ffs/pass1.c
index 010054ca545..ef6d8f163cf 100644
--- a/sbin/fsck_ffs/pass1.c
+++ b/sbin/fsck_ffs/pass1.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pass1.c,v 1.30 2008/11/09 15:54:54 chl Exp $ */
+/* $OpenBSD: pass1.c,v 1.31 2009/05/29 07:57:43 otto Exp $ */
/* $NetBSD: pass1.c,v 1.16 1996/09/27 22:45:15 christos Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)pass1.c 8.1 (Berkeley) 6/5/93";
#else
-static const char rcsid[] = "$OpenBSD: pass1.c,v 1.30 2008/11/09 15:54:54 chl Exp $";
+static const char rcsid[] = "$OpenBSD: pass1.c,v 1.31 2009/05/29 07:57:43 otto Exp $";
#endif
#endif /* not lint */
@@ -102,9 +102,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;
cginosused[c] = inosused;
for (i = 0; i < inosused; i++, inumber++) {