Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/ffs ffs_superblock_validate(): ensure fs_ncg!=0 and ...



details:   https://anonhg.NetBSD.org/src/rev/a8ec7a7e79a2
branches:  trunk
changeset: 337141:a8ec7a7e79a2
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Apr 04 06:00:12 2015 +0000

description:
ffs_superblock_validate(): ensure fs_ncg!=0 and fs_maxbpg!=0 to prevent
several divisions by zero.

diffstat:

 sys/ufs/ffs/ffs_vfsops.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (29 lines):

diff -r bc94a1d49b8e -r a8ec7a7e79a2 sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c  Sat Apr 04 04:33:38 2015 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c  Sat Apr 04 06:00:12 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_vfsops.c,v 1.327 2015/03/28 19:24:04 maxv Exp $    */
+/*     $NetBSD: ffs_vfsops.c,v 1.328 2015/04/04 06:00:12 maxv Exp $    */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.327 2015/03/28 19:24:04 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.328 2015/04/04 06:00:12 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -952,6 +952,10 @@
                return 0;
        if (fs->fs_fpg == 0)
                return 0;
+       if (fs->fs_ncg == 0)
+               return 0;
+       if (fs->fs_maxbpg == 0)
+               return 0;
 
        /* Check the number of inodes per block */
        if (fs->fs_magic == FS_UFS1_MAGIC)



Home | Main Index | Thread Index | Old Index