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_ipg and fs_...



details:   https://anonhg.NetBSD.org/src/rev/bffb1b3a7e46
branches:  trunk
changeset: 336731:bffb1b3a7e46
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Mar 14 19:52:54 2015 +0000

description:
ffs_superblock_validate(): ensure fs_ipg and fs_fpg are != 0. Otherwise
division by zero in several places.

diffstat:

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

diffs (37 lines):

diff -r e4b44714b5ba -r bffb1b3a7e46 sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c  Sat Mar 14 19:06:14 2015 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c  Sat Mar 14 19:52:54 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_vfsops.c,v 1.322 2015/03/10 12:59:32 maxv Exp $    */
+/*     $NetBSD: ffs_vfsops.c,v 1.323 2015/03/14 19:52:54 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.322 2015/03/10 12:59:32 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.323 2015/03/14 19:52:54 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ffs.h"
@@ -937,10 +937,18 @@
        if (fs->fs_fsize == 0)
                return 0;
 
+       /*
+        * XXX: these values are just zero-checked to prevent obvious
+        * bugs. We need more strict checks.
+        */
        if (fs->fs_size == 0)
                return 0;
        if (fs->fs_cssize == 0)
                return 0;
+       if (fs->fs_ipg == 0)
+               return 0;
+       if (fs->fs_fpg == 0)
+               return 0;
 
        /* Check the number of inodes per block */
        if (fs->fs_magic == FS_UFS1_MAGIC)



Home | Main Index | Thread Index | Old Index