From ca305f613f3a97746df7d9325575b3999cd2e539 Mon Sep 17 00:00:00 2001 From: Ian Dowse Date: Sat, 18 May 2002 21:33:07 +0000 Subject: Fix two off-by-one errors when sanity-checking inode numbers. In ext2fs, inode numbers start at 1, so the maximum valid inode number is (s_inodes_per_group * s_groups_count), not one less. This is just a minimal change to avoid unnecessary panics and errors; some other related bugs that Bruce Evans mentioned to me are not addressed. Reviewed by: bde (ages ago) --- sys/gnu/ext2fs/ext2_alloc.c | 2 +- sys/gnu/ext2fs/ext2_vfsops.c | 2 +- sys/gnu/fs/ext2fs/ext2_alloc.c | 2 +- sys/gnu/fs/ext2fs/ext2_vfsops.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'sys/gnu') diff --git a/sys/gnu/ext2fs/ext2_alloc.c b/sys/gnu/ext2fs/ext2_alloc.c index eeace1ef25507..a99a8ee83448d 100644 --- a/sys/gnu/ext2fs/ext2_alloc.c +++ b/sys/gnu/ext2fs/ext2_alloc.c @@ -502,7 +502,7 @@ ext2_vfree(pvp, ino, mode) pip = VTOI(pvp); fs = pip->i_e2fs; - if ((u_int)ino >= fs->s_inodes_per_group * fs->s_groups_count) + if ((u_int)ino > fs->s_inodes_per_group * fs->s_groups_count) panic("ext2_vfree: range: dev = (%d, %d), ino = %d, fs = %s", major(pip->i_dev), minor(pip->i_dev), ino, fs->fs_fsmnt); diff --git a/sys/gnu/ext2fs/ext2_vfsops.c b/sys/gnu/ext2fs/ext2_vfsops.c index c506baeefa58a..a5cbefc1ba2b0 100644 --- a/sys/gnu/ext2fs/ext2_vfsops.c +++ b/sys/gnu/ext2fs/ext2_vfsops.c @@ -1116,7 +1116,7 @@ ext2_fhtovp(mp, fhp, vpp) ufhp = (struct ufid *)fhp; fs = VFSTOEXT2(mp)->um_e2fs; if (ufhp->ufid_ino < ROOTINO || - ufhp->ufid_ino >= fs->s_groups_count * fs->s_es->s_inodes_per_group) + ufhp->ufid_ino > fs->s_groups_count * fs->s_es->s_inodes_per_group) return (ESTALE); error = VFS_VGET(mp, ufhp->ufid_ino, LK_EXCLUSIVE, &nvp); diff --git a/sys/gnu/fs/ext2fs/ext2_alloc.c b/sys/gnu/fs/ext2fs/ext2_alloc.c index eeace1ef25507..a99a8ee83448d 100644 --- a/sys/gnu/fs/ext2fs/ext2_alloc.c +++ b/sys/gnu/fs/ext2fs/ext2_alloc.c @@ -502,7 +502,7 @@ ext2_vfree(pvp, ino, mode) pip = VTOI(pvp); fs = pip->i_e2fs; - if ((u_int)ino >= fs->s_inodes_per_group * fs->s_groups_count) + if ((u_int)ino > fs->s_inodes_per_group * fs->s_groups_count) panic("ext2_vfree: range: dev = (%d, %d), ino = %d, fs = %s", major(pip->i_dev), minor(pip->i_dev), ino, fs->fs_fsmnt); diff --git a/sys/gnu/fs/ext2fs/ext2_vfsops.c b/sys/gnu/fs/ext2fs/ext2_vfsops.c index c506baeefa58a..a5cbefc1ba2b0 100644 --- a/sys/gnu/fs/ext2fs/ext2_vfsops.c +++ b/sys/gnu/fs/ext2fs/ext2_vfsops.c @@ -1116,7 +1116,7 @@ ext2_fhtovp(mp, fhp, vpp) ufhp = (struct ufid *)fhp; fs = VFSTOEXT2(mp)->um_e2fs; if (ufhp->ufid_ino < ROOTINO || - ufhp->ufid_ino >= fs->s_groups_count * fs->s_es->s_inodes_per_group) + ufhp->ufid_ino > fs->s_groups_count * fs->s_es->s_inodes_per_group) return (ESTALE); error = VFS_VGET(mp, ufhp->ufid_ino, LK_EXCLUSIVE, &nvp); -- cgit v1.3