Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs/ext2fs e2fs_sbcheck(): add a check to ensure e2fs_bp...



details:   https://anonhg.NetBSD.org/src/rev/b10639ee1a4d
branches:  trunk
changeset: 336227:b10639ee1a4d
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Feb 19 21:31:44 2015 +0000

description:
e2fs_sbcheck(): add a check to ensure e2fs_bpg!=0. Otherwise the kernel
panics with a division by zero.

While here, remove the #ifdef's.

diffstat:

 sys/ufs/ext2fs/ext2fs_vfsops.c |  13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diffs (44 lines):

diff -r 9522eb42fe2b -r b10639ee1a4d sys/ufs/ext2fs/ext2fs_vfsops.c
--- a/sys/ufs/ext2fs/ext2fs_vfsops.c    Thu Feb 19 20:57:36 2015 +0000
+++ b/sys/ufs/ext2fs/ext2fs_vfsops.c    Thu Feb 19 21:31:44 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ext2fs_vfsops.c,v 1.186 2014/11/09 18:23:28 maxv Exp $ */
+/*     $NetBSD: ext2fs_vfsops.c,v 1.187 2015/02/19 21:31:44 maxv Exp $ */
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.186 2014/11/09 18:23:28 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.187 2015/02/19 21:31:44 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -1151,20 +1151,21 @@
                return (EINVAL);                /* XXX needs translation */
        }
        if (fs2h32(fs->e2fs_rev) > E2FS_REV1) {
-#ifdef DIAGNOSTIC
                printf("ext2fs: unsupported revision number: %x\n",
                    fs2h32(fs->e2fs_rev));
-#endif
                return (EINVAL);                /* XXX needs translation */
        }
        if (fs2h32(fs->e2fs_log_bsize) > 2) { /* block size = 1024|2048|4096 */
-#ifdef DIAGNOSTIC
                printf("ext2fs: bad block size: %d "
                    "(expected <= 2 for ext2 fs)\n",
                    fs2h32(fs->e2fs_log_bsize));
-#endif
                return (EINVAL);           /* XXX needs translation */
        }
+       if (fs->e2fs_bpg == 0) {
+               printf("ext2fs: zero blocks per group\n");
+               return EINVAL;
+       }
+       
        if (fs2h32(fs->e2fs_rev) > E2FS_REV0) {
                char buf[256];
                if (fs2h32(fs->e2fs_first_ino) != EXT2_FIRSTINO) {



Home | Main Index | Thread Index | Old Index